Esp32/esp32 neo pixel

From Federal Burro of Information
Revision as of 04:22, 11 October 2022 by David (talk | contribs) (Created page with "<per> #include <Adafruit_NeoPixel.h> // Which pin on the Arduino is connected to the NeoPixels? #define PIN 8 // On Trinket or Gemma, suggest changing this to 1 // How many NeoPixels are attached to the Arduino? #define NUMPIXELS 1 // Popular NeoPixel ring size // When setting up the NeoPixel library, we tell it how many pixels, // and which pin to use to send signals. Note that for older NeoPixel // strips you might need to change the third parameter -- see t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

<per>

  1. include <Adafruit_NeoPixel.h>


// Which pin on the Arduino is connected to the NeoPixels?

  1. define PIN 8 // On Trinket or Gemma, suggest changing this to 1

// How many NeoPixels are attached to the Arduino?

  1. define NUMPIXELS 1 // Popular NeoPixel ring size

// When setting up the NeoPixel library, we tell it how many pixels, // and which pin to use to send signals. Note that for older NeoPixel // strips you might need to change the third parameter -- see the // strandtest example for more information on possible values. Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

  1. define DELAYVAL 500 // Time (in milliseconds) to pause between pixels

void setup() {

 // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
 // Any other board, you can remove this part (but no harm leaving it):
  1. if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
 clock_prescale_set(clock_div_1);
  1. endif
 // END of Trinket-specific code.
 pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)

}

void loop() {

 pixels.clear(); // Set all pixel colors to 'off'
 // The first NeoPixel in a strand is #0, second is 1, all the way up
 // to the count of pixels minus one.
 for(int i=0; i<255; i++) { // For each pixel...
   // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
   // Here we're using a moderately bright green color:
   pixels.setPixelColor(0, pixels.Color(0, i, 0));
   pixels.show();   // Send the updated pixel colors to the hardware.
   delay(DELAYVAL); // Pause before next pass through loop
 }

}