Guest User

Untitled

a guest
Apr 27th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #define PIN 8
  3. #define N_LEDS 14
  4. Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
  5.  
  6. int photocellPin = 0;
  7. int photocellReading;
  8.  
  9. void setup() {
  10. strip.begin();
  11.  
  12. Serial.begin(9600);
  13. }
  14.  
  15. void loop() {
  16. chase(strip.Color(255, 0, 0));
  17. chase(strip.Color(0, 255, 0));
  18. chase(strip.Color(0, 0, 255));
  19.  
  20. photocellReading = analogRead(photocellPin);
  21. Serial.print("Analog reading = ");
  22. Serial.println(photocellReading);
  23. }
  24.  
  25. static void chase(uint32_t c) {
  26. if(photocellReading <= 300) {
  27. for (uint16_t i = 0; i < strip.numPixels() + 4; i++) {
  28. strip.setPixelColor(i , c);
  29. strip.setPixelColor(i - 4, 0);
  30. strip.show();
  31. delay(20);
  32. }
  33. }
  34. }
Add Comment
Please, Sign In to add comment