Advertisement
microrobotics

Adafruit Nexpixel Shield

Aug 1st, 2017
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.62 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 AdaFruit NeoPixel library
  3.  
  4. #include <Adafruit_NeoPixel.h>
  5. #ifdef __AVR__
  6.   #include <avr/power.h>
  7. #endif
  8.  
  9. // Which pin on the Arduino is connected to the NeoPixels?
  10. // On a Trinket or Gemma we suggest changing this to 1
  11. #define PIN            6
  12.  
  13. // How many NeoPixels are attached to the Arduino?
  14. #define NUMPIXELS      16
  15.  
  16. // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
  17. // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
  18. // example for more information on possible values.
  19. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  20.  
  21. int delayval = 500; // delay for half a second
  22.  
  23. void setup() {
  24.   // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  25. #if defined (__AVR_ATtiny85__)
  26.   if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  27. #endif
  28.   // End of trinket special code
  29.  
  30.   pixels.begin(); // This initializes the NeoPixel library.
  31. }
  32.  
  33. void loop() {
  34.  
  35.   // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  36.  
  37.   for(int i=0;i<NUMPIXELS;i++){
  38.  
  39.     // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
  40.     pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
  41.  
  42.     pixels.show(); // This sends the updated pixel color to the hardware.
  43.  
  44.     delay(delayval); // Delay for a period of time (in milliseconds).
  45.  
  46.   }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement