1
2
3
4
5int red = 11;
6int green = 10;
7int blue = 9;
8
9int Switch1 = 2;
10int Switch2 = 3;
11int Switch3 = 4;
12
13void setup() {
14
15
16 pinMode(red, OUTPUT);
17 pinMode(green, OUTPUT);
18 pinMode(blue, OUTPUT);
19 pinMode(Switch1, INPUT);
20 pinMode(Switch2, INPUT);
21 pinMode(Switch3, INPUT);
22}
23
24void RGB_color(int red_value, int green_value, int blue_value)
25{
26
27
28 analogWrite(red, red_value);
29 analogWrite(green, green_value);
30 analogWrite(blue, blue_value);
31}
32
33
34
35void loop() {
36
37 if (digitalRead(Switch1) == HIGH && digitalRead(Switch2) != HIGH && digitalRead(Switch3) != HIGH)
38
39 {
40 RGB_color(125, 0, 0);
41 delay(800);
42 RGB_color(0, 125, 0);
43 delay(800);
44
45 }
46 else if (digitalRead(Switch2) == HIGH && digitalRead(Switch1) != HIGH && digitalRead(Switch3) != HIGH)
47 {
48 RGB_color(0, 0, 125);
49 delay(800);
50 RGB_color(64, 32, 0);
51 delay(800);
52 }
53 else if (digitalRead(Switch3) == HIGH && digitalRead(Switch2) != HIGH && digitalRead(Switch1) != HIGH)
54 {
55 RGB_color(125, 0, 125);
56 delay(800);
57 RGB_color(125, 125, 125);
58 delay(800);
59 }
60 else if (digitalRead(Switch1) == HIGH && digitalRead(Switch2) == HIGH && digitalRead(Switch3) != HIGH)
61 {
62 RGB_color(125, 0, 0);
63 delay(800);
64 RGB_color(0, 125, 0);
65 delay(800);
66 RGB_color(0, 0, 125);
67 delay(800);
68 RGB_color(64, 32, 0);
69 delay(800);
70
71 }
72 else if (digitalRead(Switch1) == HIGH && digitalRead(Switch3) == HIGH && digitalRead(Switch2) != HIGH)
73 {
74 RGB_color(125, 0, 0);
75 delay(800);
76 RGB_color(0, 125, 0);
77 delay(800);
78 RGB_color(125, 0, 125);
79 delay(800);
80 RGB_color(125, 125, 125);
81 delay(800);
82 }
83 else if (digitalRead(Switch2) == HIGH && digitalRead(Switch3) == HIGH && digitalRead(Switch1) != HIGH)
84 {
85 RGB_color(0, 0, 125);
86 delay(800);
87 RGB_color(64, 32, 0);
88 delay(800);
89 RGB_color(125, 0, 125);
90 delay(800);
91 RGB_color(125, 125, 125);
92 delay(800);
93
94 }
95 else if (digitalRead(Switch2) == HIGH && digitalRead(Switch3) == HIGH && digitalRead(Switch1) == HIGH)
96 {
97 RGB_color(125, 0, 0);
98 delay(800);
99 RGB_color(0, 125, 0);
100 delay(800);
101 RGB_color(0, 0, 125);
102 delay(800);
103 RGB_color(64, 32, 0);
104 delay(800);
105 RGB_color(125, 0, 125);
106 delay(800);
107 RGB_color(125, 125, 125);
108 delay(800);
109 }
110 else if (digitalRead(Switch2) != HIGH && digitalRead(Switch3) != HIGH && digitalRead(Switch1) != HIGH)
111 {
112 RGB_color(0,0,0);
113 delay(500);
114 }
115
116}