Krolyxon
Commit 1d55752

Branches

Tags

Refs →

orion-rf.piolibdepsesp32-s3-n16r8Adafruit NeoPixelexamplessimplesimple.ino

50 lines · 1.8 KB

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 16 // 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.
20Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
21
22#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
23
24void 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}
34
35void loop() {
36 pixels.clear(); // Set all pixel colors to 'off'
37
38 // The first NeoPixel in a strand is #0, second is 1, all the way up
39 // to the count of pixels minus one.
40 for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
41
42 // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
43 // Here we're using a moderately bright green color:
44 pixels.setPixelColor(i, pixels.Color(0, 150, 0));
45
46 pixels.show(); // Send the updated pixel colors to the hardware.
47
48 delay(DELAYVAL); // Pause before next pass through loop
49 }
50}