// Source: NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
//####################################################################################################################
// This is sample code for Ampel - a WS2812 (Neopixel Stick) Traffic Light
// Based on a 3D printed housing together with a WS2812 LED Stick
// 3D print files: https://www.printables.com/model/864750
// As I was not able to find a Neopixel Stick in WOKWI the scheme uses a Neopixel ring with the same number of LEDs
// Before connecting make sure to read and understand a more detailed instruction about
// wiring and powering the LED stick. You can find it at: https://learn.adafruit.com/adafruit-neopixel-uberguide/powering-neopixels
// Disclaimer:
// Use at your own risk. This is an example only. I do not take any liability for damages or injuries.
// ###################################################################################################################
#include <Adafruit_NeoPixel.h>
// Which pin on the ESP32 is connected to the NeoPixels?
#define PIN 16 // Connect GPIO16 to DIN at the LED stick
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 8 // NeoPixel stick has 8 pixels
// 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);
#define DELAYVAL 1000 // Time (in milliseconds) to pause between pixels
void setup() {
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
void loop() {
pixels.clear(); // Set all pixel colors to 'off'
pixels.setPixelColor(0, pixels.Color(255, 0, 0)); // Set pixel 0 to red
// pixels.setPixelColor(1, pixels.Color(255, 0, 0)); // Set pixel 1 to red
pixels.show(); // Send the updated pixel colors to the hardware.
delay(DELAYVAL); // Pause before next step
pixels.clear(); // Set all pixel colors to 'off'
// pixels.setPixelColor(3, pixels.Color(255, 150, 0)); // Set pixel 3 to yellow
pixels.setPixelColor(4, pixels.Color(255, 150, 0)); // Set pixel 4 to yellow
pixels.show(); // Send the updated pixel colors to the hardware.
delay(DELAYVAL); // Pause before next step
pixels.clear(); // Set all pixel colors to 'off'
// pixels.setPixelColor(6, pixels.Color(255, 150, 0)); // Set pixel 6 to green
pixels.setPixelColor(7, pixels.Color(0, 255, 0)); // Set pixel 7 to green
pixels.show(); // Send the updated pixel colors to the hardware.
delay(DELAYVAL); // Pause before next pass through loop
/* Color codes
// RED = (255, 0, 0)
// YELLOW = (255, 150, 0)
// GREEN = (0, 255, 0)
*/
}