-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLab_Status_Light.ino
More file actions
67 lines (55 loc) · 2.08 KB
/
Copy pathLab_Status_Light.ino
File metadata and controls
67 lines (55 loc) · 2.08 KB
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
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
const int buttonPin2 = 3; // the number of the floatswitch pin 2
const int PIN = 2; // the number of the LED pin 3
int buttonState = 0;
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, PIN, NEO_GRB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.
void setup() {
// initialize the LED pin as an output:
pinMode(PIN, OUTPUT);
pinMode(buttonPin2, INPUT_PULLUP);
// initialize the LED pin as an output:
strip.begin();
strip.setBrightness(100);
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin2);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
colorWipeS(strip.Color(255, 0, 0), 50); // Red
colorWipeS(strip.Color(0, 0, 0), 50); // Blank/off
} else {
colorWipe(strip.Color(0, 255, 0)); // Green?
}
}
// Fill the dots one after the other with a color
void colorWipeS(uint32_t c, uint8_t wait) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void colorWipe(uint32_t c) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
}
}