-
Notifications
You must be signed in to change notification settings - Fork 0
/
KemaLED.cpp
58 lines (46 loc) · 1.05 KB
/
KemaLED.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// (c) https://vk.com/myrobotics
#include "Arduino.h"
#include "KemaLED.h"
KemaLED::KemaLED(int rPin, int gPin, int bPin)
{
_rPin = rPin;
_gPin = gPin;
_bPin = bPin;
pinMode(_rPin, OUTPUT);
pinMode(_gPin, OUTPUT);
pinMode(_bPin, OUTPUT);
analogWrite(_rPin, 0);
analogWrite(_gPin, 0);
analogWrite(_bPin, 0);
}
void KemaLED::led(char color)
{
switch (color)
{
case 'R':
analogWrite(_rPin, 0);
analogWrite(_gPin, 255);
analogWrite(_bPin, 255);
break;
case 'G':
analogWrite(_rPin, 255);
analogWrite(_gPin, 0);
analogWrite(_bPin, 255);
break;
case 'B':
analogWrite(_rPin, 255);
analogWrite(_gPin, 255);
analogWrite(_bPin, 0);
break;
case 'Y':
analogWrite(_rPin, 0);
analogWrite(_gPin, 75);
analogWrite(_bPin, 255);
break;
case 'W':
analogWrite(_rPin, 0);
analogWrite(_gPin, 0);
analogWrite(_bPin, 0);
break;
}
}