Guest User

Untitled

a guest
May 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #ifdef __AVR__
  3. #include <avr/power.h>
  4. #endif
  5.  
  6. #define PIN 12
  7. #define NUMPIXELS 5
  8.  
  9. #define PIN2 8
  10. #define NUMPIXELS2 19
  11.  
  12. #define PIN3 13
  13. #define NUMPIXELS3 5
  14.  
  15. #define BRIGHTNESS 255
  16.  
  17. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  18. Adafruit_NeoPixel pixelsLong = Adafruit_NeoPixel(NUMPIXELS2, PIN2, NEO_GRB + NEO_KHZ800);
  19. Adafruit_NeoPixel pixelsShort = Adafruit_NeoPixel(NUMPIXELS3, PIN3, NEO_GRB + NEO_KHZ800);
  20.  
  21. int delayval = 100;
  22.  
  23. int pot1;
  24. int pot2;
  25. int pot3;
  26. int color;
  27.  
  28.  
  29. void setup() {
  30. // put your setup code here, to run once:
  31. pixels.begin();
  32. pixelsLong.begin();
  33. pixelsShort.begin();
  34. pixels.setBrightness(BRIGHTNESS);
  35. pixelsLong.setBrightness(BRIGHTNESS);
  36. pixelsShort.setBrightness(BRIGHTNESS);
  37. // Serial.begin(9600);
  38. }
  39.  
  40. void loop() {
  41. // put your main code here, to run repeatedly:
  42. pot1 = analogRead(A5);
  43. pot2 = analogRead(A4);
  44. pot3 = analogRead(A3);
  45.  
  46. int pot1Map = map(pot1, 0, 1023, 0, 255);
  47. int pot2Map = map(pot2, 0, 1023, 0, 255);
  48. int pot3Map = map(pot3, 0, 1023, 0, 255);
  49.  
  50. for(int i=0;i<NUMPIXELS;i++){
  51.  
  52. pixels.setPixelColor(i, pixels.Color(pot1Map,pot2Map,pot3Map));
  53. pixels.show();
  54.  
  55. pixelsShort.setPixelColor(i, pixelsShort.Color(pot1Map,pot2Map,pot3Map));
  56. pixelsShort.show();
  57.  
  58. delay(delayval);
  59.  
  60. }
  61.  
  62. for(int i=0;i<NUMPIXELS2;i++){
  63.  
  64. pixelsLong.setPixelColor(i, pixelsLong.Color(pot1Map,pot2Map,pot3Map));
  65. pixelsLong.show();
  66.  
  67. delay(delayval);
  68.  
  69. }
  70.  
  71. }
Add Comment
Please, Sign In to add comment