-
Notifications
You must be signed in to change notification settings - Fork 12
/
rgb_led.cpp
63 lines (53 loc) · 1.14 KB
/
rgb_led.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
59
60
61
62
63
#include "rgb_led.h"
void ledInit() {
pinMode(LED_R, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
}
#ifdef COMMON_ANODE
#define LED_ON LOW
#define LED_OFF HIGH
#else
#define LED_ON HIGH
#define LED_OFF LOW
#endif
void ledRed() {
digitalWrite(LED_R, LED_ON);
digitalWrite(LED_G, LED_OFF);
digitalWrite(LED_B, LED_OFF);
}
void ledGreen() {
digitalWrite(LED_R, LED_OFF);
digitalWrite(LED_G, LED_ON);
digitalWrite(LED_B, LED_OFF);
}
void ledBlue() {
digitalWrite(LED_R, LED_OFF);
digitalWrite(LED_G, LED_OFF);
digitalWrite(LED_B, LED_ON);
}
void ledYellow() {
digitalWrite(LED_R, LED_ON);
digitalWrite(LED_G, LED_ON);
digitalWrite(LED_B, LED_OFF);
}
void ledMagenta() {
digitalWrite(LED_R, LED_ON);
digitalWrite(LED_G, LED_OFF);
digitalWrite(LED_B, LED_ON);
}
void ledCyan() {
digitalWrite(LED_R, LED_OFF);
digitalWrite(LED_G, LED_ON);
digitalWrite(LED_B, LED_ON);
}
void ledBlack() {
digitalWrite(LED_R, LED_OFF);
digitalWrite(LED_G, LED_OFF);
digitalWrite(LED_B, LED_OFF);
}
void ledWhite() {
digitalWrite(LED_R, LED_ON);
digitalWrite(LED_G, LED_ON);
digitalWrite(LED_B, LED_ON);
}