-
Notifications
You must be signed in to change notification settings - Fork 0
/
ledpy.ino
80 lines (63 loc) · 1.32 KB
/
ledpy.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
int g = 9;
int r = 10;
int b = 11;
int y = 3;
int w = 5;
int rr = 40;
int rg = 30;
int ry = 30;
int rw = 8;
int rb = 8;
void setup() {
Serial.begin(9600);
pinMode(r, OUTPUT);
pinMode(g, OUTPUT);
pinMode(b, OUTPUT);
pinMode(y, OUTPUT);
pinMode(w, OUTPUT);
}
void loop() {
if(Serial.available() > 0) {
int data = Serial.read();
Serial.print(data);
data = data-48;
if(data == 1){
shine(g, 250);
shine(r, random(rr)/1);
shine(b, random(rb)/1);
shine(y, random(ry)/1);
shine(w, random(rw)/1);
}
else if (data == 2){
shine(r,250);
shine(g,random(rg)/1);
shine(b,random(rb)/1);
shine(y,random(ry)/1);
shine(w,random(rw)/1);
}
else if (data == 3){
shine(y,250);
shine(r,random(rr)/1);
shine(g,random(rg)/1);
shine(b,random(rb)/1);
shine(w,random(rw)/1);
}
else if (data == 4){
shine(b,200);
shine(r,random(rr)/1);
shine(g,random(rg)/1);
shine(y,random(ry)/1);
shine(w,random(rw)/1);
}
else if (data == 5){
shine(w,30);
shine(r,random(rr)/1);
shine(g,random(rg)/1);
shine(b,random(rb)/1);
shine(y,random(ry)/1);
}
}
}
void shine(int pinNum, int intensity){
analogWrite(pinNum, intensity);
}