-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathled_RGB_diver.ino
More file actions
executable file
·43 lines (39 loc) · 1.01 KB
/
led_RGB_diver.ino
File metadata and controls
executable file
·43 lines (39 loc) · 1.01 KB
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
/************************* LED io *************************/
#define RGB_LED_R 2
#define RGB_LED_G 3
#define RGB_LED_B 5
enum rgb_mode_e{
RED = 0,
GREEN,
BLUE,
} rgb_mode = RED;
void setup() {
// put your setup code here, to run once:
pinMode(RGB_LED_R, OUTPUT);
pinMode(RGB_LED_G, OUTPUT);
pinMode(RGB_LED_B, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
switch( rgb_mode ){
case RED:
digitalWrite(RGB_LED_R,LOW);
digitalWrite(RGB_LED_G,HIGH);
digitalWrite(RGB_LED_B,HIGH);
rgb_mode = GREEN;
break;
case GREEN:
digitalWrite(RGB_LED_R,HIGH);
digitalWrite(RGB_LED_G,LOW);
digitalWrite(RGB_LED_B,HIGH);
rgb_mode = BLUE;
break;
case BLUE:
digitalWrite(RGB_LED_R,HIGH);
digitalWrite(RGB_LED_G,HIGH);
digitalWrite(RGB_LED_B,LOW);
rgb_mode = RED;
break;
}
delay(500);
}