Skip to content

Commit 7a5a154

Browse files
authored
버튼 누를시 점등코드
1 parent a1872b5 commit 7a5a154

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

button_on.ino

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}

0 commit comments

Comments
 (0)