-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduino4
104 lines (68 loc) · 1.61 KB
/
arduino4
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
#include <FastLED.h>
#define NUM_LEDS1 3
#define LED_PIN1 0
#define NUM_LEDS2 3
#define LED_PIN2 1
#define NUM_LEDS3 3
#define LED_PIN3 2
#define NUM_LEDS4 3
#define LED_PIN4 3
#define NUM_LEDS5 3
#define LED_PIN5 4
int p;
int r[4]={209,230,226,140};
int g[4]={178,121,66,26};
int l[4]={26,93,26,226};
CRGB leds1[NUM_LEDS1];
CRGB leds2[NUM_LEDS2];
CRGB leds3[NUM_LEDS3];
CRGB leds4[NUM_LEDS4];
CRGB leds5[NUM_LEDS5];
void setup()
{
Serial.begin(9600);
pinMode(5,INPUT);
pinMode(6,INPUT);
pinMode(7,INPUT);
pinMode(8,INPUT);
pinMode(9,INPUT);
Serial.begin(9600);
FastLED.addLeds<WS2812, LED_PIN1, GRB>(leds1, NUM_LEDS1);
FastLED.addLeds<WS2812, LED_PIN2, GRB>(leds2, NUM_LEDS2);
FastLED.addLeds<WS2812, LED_PIN3, GRB>(leds3, NUM_LEDS3);
FastLED.addLeds<WS2812, LED_PIN4, GRB>(leds4, NUM_LEDS4);
FastLED.addLeds<WS2812, LED_PIN5, GRB>(leds5, NUM_LEDS5);
}
void loop()
{
if ( digitalRead(5) == 0 )
{ p=random(5);
leds1[0] = CRGB(r[p],g[p],l[p]);
FastLED.show();
delay(1000);
}
if ( digitalRead(6) == 0)
{ p=random(5);
leds2[0] = CRGB(r[p],g[p],l[p]);
FastLED.show();
delay(1000);
}
if ( digitalRead(7) == 0 )
{ p=random(5);
leds3[0] = CRGB(r[p],g[p],l[p]);
FastLED.show();
delay(1000);
}
if ( digitalRead(8) == 0 )
{ p=random(5);
leds4[0] = CRGB(r[p],g[p],l[p]);
FastLED.show();
delay(1000);
}
if ( digitalRead(9) == 0 )
{ p=random(5);
leds5[0] = CRGB(r[p],g[p],l[p]);
FastLED.show();
delay(1000);
}
}