Skip to content

Instantly share code, notes, and snippets.

@urish
Last active November 6, 2021 20:16
Show Gist options
  • Save urish/19e3922f4d8468bbe6bc to your computer and use it in GitHub Desktop.
Save urish/19e3922f4d8468bbe6bc to your computer and use it in GitHub Desktop.
Simple NeoPixel Animation for Arduino on WeMos D1 Mini, License: MIT
#include <Adafruit_NeoPixel.h>
#define NUM_PIXELS 24
Adafruit_NeoPixel pixels(NUM_PIXELS, D2, NEO_GRB | NEO_KHZ800);
void setup() {
pixels.begin();
}
void setColor(uint32_t color) {
for (int i = 0; i < NUM_PIXELS; i++) {
pixels.setPixelColor(i, color);
pixels.show();
delay(50);
}
}
void loop() {
setColor(pixels.Color(100, 0, 0));
delay(1000);
setColor(pixels.Color(0, 100, 0));
delay(1000);
setColor(pixels.Color(0, 0, 100));
delay(1000);
}
@idesignstuff
Copy link

If this is for an ESP, isn't the delay function a bad idea? This should use a timer and millis, and there is a lib called simple timer that makes it easy. If you use delay with wifi functions, it can lose the wifi connection.

@AAli77
Copy link

AAli77 commented May 28, 2017

Hi, Need help.....! I am unisg WeMos D1R2 and WS2812B Led Lights. I had use your code but nothing happening. Can you please help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment