-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial_out.ino
111 lines (91 loc) · 1.63 KB
/
serial_out.ino
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
int inc;
// Output
int r = 9; // Red LED, connected to digital pin 9
int g = 10; // Green LED, connected to digital pin 10
int b = 11; // Blue LED, connected to digital pin 11
void setup()
{
Serial.begin(9600);
pinMode(r, OUTPUT); // sets the pins as output
pinMode(g, OUTPUT);
pinMode(b, OUTPUT);
}
void loop()
{
if (Serial.available()>0)
{
inc= Serial.read();
if(inc == '1')
{
analogWrite(r, 255);
analogWrite(g,LOW);
analogWrite(b, 255);
}
if(inc == '2')
{
analogWrite(r, 255);
analogWrite(g,2);
analogWrite(b, 255);
}
if(inc == '3')
{
analogWrite(r, 255);
analogWrite(g,64);
analogWrite(b, 255);
}
if(inc == '4')
{
analogWrite(r, 255);
analogWrite(g,96);
analogWrite(b, 255);
}
if(inc == '5')
{
analogWrite(r, 255);
analogWrite(g,128);
analogWrite(b, 255);
}
if(inc == '6')
{
analogWrite(r, 255);
analogWrite(g,154);
analogWrite(b, 255);
}
if(inc == '7')
{
analogWrite(r, 255);
analogWrite(g,180);
analogWrite(b, 255);
}
if(inc == '8')
{
analogWrite(r, 255);
analogWrite(g,206);
analogWrite(b, 255);
}
if(inc == '9')
{
analogWrite(r, LOW);
analogWrite(g,186);
analogWrite(b, 255);
}
if(inc == '0')
{
analogWrite(r, LOW);
analogWrite(g,255);
analogWrite(b, 255);
}
if(inc == 'B')
{
analogWrite(r, 2);
analogWrite(g,25);
analogWrite(b, 255);
}
if(inc == 'C')
{
analogWrite(r, 255);
analogWrite(g,255);
analogWrite(b, LOW);
}
}
}