Guest User

Untitled

a guest
May 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #ifdef __AVR__
  3. #include <avr/power.h>
  4. #endif
  5.  
  6. #define PIN 6
  7. #define NUMPIXELS 16
  8.  
  9. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  10.  
  11. #define PIN_R 2
  12. #define PIN_G 3
  13. #define PIN_B 4
  14. int red_in;
  15. int green_in;
  16. int blue_in;
  17.  
  18. void setup() {
  19. // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  20. #if defined (__AVR_ATtiny85__)
  21. if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  22. #endif
  23. // End of trinket special code
  24.  
  25. pixels.begin(); // This initializes the NeoPixel library.
  26. }
  27.  
  28. void loop() {
  29. red_in = digitalRead(PIN_R);
  30. green_in = digitalRead(PIN_G);
  31. blue_in = digitalRead(PIN_B);
  32.  
  33. for(int i=0;i<NUMPIXELS;i++){
  34. pixels.setPixelColor(i, pixels.Color(150*red_in, 150*green_in, 150*blue_in));
  35. pixels.show(); // This sends the updated pixel color to the hardware.
  36. }
  37. }
Add Comment
Please, Sign In to add comment