Esp32 neopixel hello world.ino

From Federal Burro of Information
Revision as of 01:52, 15 October 2021 by David (talk | contribs) (Created page with " <pre> #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> #endif #define PIN 8 #define NUMPIXELS 1 Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif
#define PIN        8
#define NUMPIXELS 1

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 250

void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif

  pixels.begin();
}

void loop() {
  pixels.clear();

  for(int i=0; i<NUMPIXELS; i++) {

// Colour  R   G   B
// Red     255 0   0
// Orange  255 32  0
// Yellow  255 127 0
// Green   0   255 0
// Blue    0   0   255
// Indigo  40  0   255
// Violet  255 0    80

//                                       R   G     B
    // Red
    pixels.setPixelColor(i, pixels.Color(255, 0, 0));
    pixels.show();
    delay(DELAYVAL);

    // Orange
    pixels.setPixelColor(i, pixels.Color(255, 32, 0));
    pixels.show();
    delay(DELAYVAL);

    // Yellow
    pixels.setPixelColor(i, pixels.Color(255, 127, 0));
    pixels.show();
    delay(DELAYVAL);

    // Green
    pixels.setPixelColor(i, pixels.Color(0, 255, 0));
    pixels.show();
    delay(DELAYVAL);

    // Blue
    pixels.setPixelColor(i, pixels.Color(0, 0, 255));
    pixels.show();
    delay(DELAYVAL);

    // Indigo
    pixels.setPixelColor(i, pixels.Color(40, 0, 255));
    pixels.show();
    delay(DELAYVAL);

     // Violet
    pixels.setPixelColor(i, pixels.Color(255, 0, 80));
    pixels.show();
    delay(DELAYVAL);
  }
}