Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. // NeoPixel Ring simple sketch (c) 2013 Shae Erisson
  2. // Released under the GPLv3 license to match the rest of the
  3. // Adafruit NeoPixel library
  4.  
  5. #include <Adafruit_NeoPixel.h>
  6. #ifdef __AVR__
  7. #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
  8. #endif
  9.  
  10. // Which pin on the Arduino is connected to the NeoPixels?
  11. #define PIN 6 // On Trinket or Gemma, suggest changing this to 1
  12.  
  13. // How many NeoPixels are attached to the Arduino?
  14. #define NUMPIXELS 4 // Popular NeoPixel ring size
  15.  
  16. // When setting up the NeoPixel library, we tell it how many pixels,
  17. // and which pin to use to send signals. Note that for older NeoPixel
  18. // strips you might need to change the third parameter -- see the
  19. // strandtest example for more information on possible values.
  20. Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  21.  
  22. #define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
  23.  
  24. void setup() {
  25. // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  26. // Any other board, you can remove this part (but no harm leaving it):
  27. #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  28. clock_prescale_set(clock_div_1);
  29. #endif
  30. // END of Trinket-specific code.
  31.  
  32. pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  33. Serial.begin(9600);
  34. }
  35.  
  36. void loop() {
  37. int pot = analogRead(0);
  38. int green = map(pot, 0, 374, 1, 5);
  39. if(pot <= 0 && pot >= 74){
  40. //eteindre les LEDS
  41. }
  42.  
  43. Serial.println(green);
  44.  
  45. pixels.clear(); // Set all pixel colors to 'off'
  46.  
  47. // The first NeoPixel in a strand is #0, second is 1, all the way up
  48. // to the count of pixels minus one.
  49. for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
  50.  
  51. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
  52. // Here we're using a moderately bright green color:
  53. pixels.setPixelColor(i, pixels.Color(0, green, 0));
  54.  
  55. pixels.show(); // Send the updated pixel colors to the hardware.
  56.  
  57. delay(DELAYVAL); // Pause before next pass through loop
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement