Home ESP8266 Various Wemos RGB LED Shield examples

Various Wemos RGB LED Shield examples

by iainhendry

Here are a few code examples for the Wemos RGB LED Shield, the shield consists of

  • 7 RGB LEDs (WS2812B-mini) each wtih 24-bit RGB color
  • 9 optional control pins (Default: D4/GPIO2)
RGB LED Shield

RGB LED Shield

It fits on a Wemos mini and is easy to create examples, you simply need to add the adafruit neopixel library in the library manager in the Arduino IDE

 

Example 1

This is the default example
[codesyntax]

#include <Adafruit_NeoPixel.h>

#define PIN D4
#define LED_NUM 7

Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800);

void setup()
{
leds.begin(); // This initializes the NeoPixel library.
}

void led_set(uint8 R, uint8 G, uint8 B)
{
for (int i = 0; i < LED_NUM; i++)
{
leds.setPixelColor(i, leds.Color(R, G, B));
leds.show();
delay(50);
}
}

void loop()
{
led_set(10, 0, 0);//red
led_set(0, 0, 0);
led_set(0, 10, 0);//green
led_set(0, 0, 0);
led_set(0, 0, 10);//blue
led_set(0, 0, 0);
}

[/codesyntax]

 

Example 2

[codesyntax]

#include <Adafruit_NeoPixel.h>

#define PIN D4
#define LED_NUM 7

Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800);

void setup()
{
leds.begin(); // This initializes the NeoPixel library.
}

void led_set(uint8 R, uint8 G, uint8 B)
{
for (int i = 0; i < LED_NUM; i++)
{
leds.setPixelColor(i, leds.Color(R, G, B));
leds.show();
//delay(50);
}
}

void loop()
{

led_set(10, 0, 0);//red
delay(1500);
led_set(0, 0, 0);
delay(1500);
led_set(0, 10, 0);//green
delay(1500);
led_set(0, 0, 0);
delay(1500);
led_set(0, 0, 10);//blue
delay(1500);
led_set(0, 0, 0);
delay(1500);
}

[/codesyntax]

 

Example 3

[codesyntax]

//random red LED

#include <Adafruit_NeoPixel.h>

#define PIN D4
#define LED_NUM 7

Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800);

int rndLed;

void setup()
{
leds.begin(); // This initializes the NeoPixel library.
randomSeed(analogRead(0));
}

void loop()
{
rndLed = random(0, 7);
leds.setPixelColor(rndLed, leds.Color(5, 0, 0));
leds.show();
delay(500);
leds.setPixelColor(rndLed, leds.Color(0, 0, 0));
leds.show();
}

[/codesyntax]

 

Example 4

[codesyntax]

#include <Adafruit_NeoPixel.h>

#define PIN D4
#define LED_NUM 7

Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800);

int rndLed;
int rndRed;
int rndGreen;
int rndBlue;

void setup()
{
leds.begin(); // This initializes the NeoPixel library.
randomSeed(analogRead(0));
}

void loop()
{
rndLed = random(0, 7);
rndRed = random(0, 7);
rndGreen = random(0, 7);
rndBlue = random(0, 7);
leds.setPixelColor(rndLed, leds.Color(rndRed, rndGreen, rndBlue));
leds.show();
delay(250);
leds.setPixelColor(rndLed, leds.Color(0, 0, 0));
leds.show();
}

[/codesyntax]

 

Example 5

[codesyntax]

#include <Adafruit_NeoPixel.h>

#define PIN D4
#define LED_NUM 7

Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800);

int rndLed;
int rndRed;
int rndGreen;
int rndBlue;

void setup()
{
leds.begin(); // This initializes the NeoPixel library.
randomSeed(analogRead(0));
}

void loop()
{
rndLed = random(0, 7);
rndRed = random(0, 7);
rndGreen = random(0, 7);
rndBlue = random(0, 7);
leds.setPixelColor(rndLed, leds.Color(rndRed, rndGreen, rndBlue));
leds.show();
delay(250);
}

[/codesyntax]

 

Video

Recorded this and uploaded to our Youtube channel

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More