Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #define PIN 8
- #define N_LEDS 14
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
- int photocellPin = 0;
- int photocellReading;
- void setup() {
- strip.begin();
- Serial.begin(9600);
- }
- void loop() {
- chase(strip.Color(255, 0, 0));
- chase(strip.Color(0, 255, 0));
- chase(strip.Color(0, 0, 255));
- photocellReading = analogRead(photocellPin);
- Serial.print("Analog reading = ");
- Serial.println(photocellReading);
- }
- static void chase(uint32_t c) {
- if(photocellReading <= 300) {
- for (uint16_t i = 0; i < strip.numPixels() + 4; i++) {
- strip.setPixelColor(i , c);
- strip.setPixelColor(i - 4, 0);
- strip.show();
- delay(20);
- }
- }
- }
Add Comment
Please, Sign In to add comment