File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < Adafruit_NeoPixel.h>
2
+ #define PIN 7
3
+ #define NUM_LEDS 4
4
+ Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
5
+ int buttonApin = 8 ;
6
+
7
+ void setup ()
8
+ {
9
+ pinMode (buttonApin, INPUT_PULLUP);
10
+ strip.begin ();
11
+ strip.show ();
12
+ }
13
+
14
+ void loop ()
15
+ {
16
+ if (digitalRead (buttonApin) == LOW)
17
+ {
18
+ strip.setPixelColor (0 , 10 , 0 , 0 );
19
+ strip.setPixelColor (1 , 0 , 0 , 0 );
20
+ strip.setPixelColor (2 , 0 , 0 , 0 );
21
+ strip.setPixelColor (3 , 0 , 0 , 0 );
22
+ strip.show ();
23
+ delay (1 );
24
+ }
25
+ if (digitalRead (buttonApin) == HIGH)
26
+ {
27
+ strip.setPixelColor (0 , 0 , 0 , 0 );
28
+ strip.setPixelColor (1 , 0 , 0 , 0 );
29
+ strip.setPixelColor (2 , 0 , 0 , 0 );
30
+ strip.setPixelColor (3 , 0 , 0 , 0 );
31
+ strip.show ();
32
+ delay (1 );
33
+ }
34
+
35
+ }
You can’t perform that action at this time.
0 commit comments