simple.ino 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include <Adafruit_NeoPixel.h>
  5. #ifdef __AVR__
  6. #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
  7. #endif
  8. // Which pin on the Arduino is connected to the NeoPixels?
  9. #define PIN 6 // On Trinket or Gemma, suggest changing this to 1
  10. // How many NeoPixels are attached to the Arduino?
  11. #define NUMPIXELS 16 // Popular NeoPixel ring size
  12. // When setting up the NeoPixel library, we tell it how many pixels,
  13. // and which pin to use to send signals. Note that for older NeoPixel
  14. // strips you might need to change the third parameter -- see the
  15. // strandtest example for more information on possible values.
  16. Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  17. #define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
  18. void setup() {
  19. // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  20. // Any other board, you can remove this part (but no harm leaving it):
  21. #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  22. clock_prescale_set(clock_div_1);
  23. #endif
  24. // END of Trinket-specific code.
  25. pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  26. }
  27. void loop() {
  28. pixels.clear(); // Set all pixel colors to 'off'
  29. // The first NeoPixel in a strand is #0, second is 1, all the way up
  30. // to the count of pixels minus one.
  31. for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
  32. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
  33. // Here we're using a moderately bright green color:
  34. pixels.setPixelColor(i, pixels.Color(0, 150, 0));
  35. pixels.show(); // Send the updated pixel colors to the hardware.
  36. delay(DELAYVAL); // Pause before next pass through loop
  37. }
  38. }