materials for TeZ Bioreactor course
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.2 KiB

// WEMOS D1 MINI ESP32 // NEOPIXEL TEST (RGB) // TeZ 2022
#include <Adafruit_NeoPixel.h>
#define PIN 5 // data pin for neopixel
#define NUMPIXELS 8 // Max number of Leds
int rgbflag = 1;
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 50 // Time (in milliseconds) to pause between pixels
int ledPin = 2; // internal led D1 Mini esp32
//////////////////////////////////
void setup() {
pinMode(ledPin, OUTPUT);
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
//////////////////////////////////
void loop() {
pixels.clear(); // Set all pixel colors to 'off'
for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
if(rgbflag == 1){
pixels.setPixelColor(i, pixels.Color(200, 0, 0)); // RED
}else if(rgbflag == 2){
pixels.setPixelColor(i, pixels.Color(0, 200, 0)); // GREEN
}else if(rgbflag == 3){
pixels.setPixelColor(i, pixels.Color(0, 0, 200)); // BLUE
}
pixels.show(); // Send the updated pixel colors to the hardware.
digitalWrite(ledPin, HIGH); // internal led ON
delay(DELAYVAL);
digitalWrite(ledPin, LOW); // internal led OFF
delay(DELAYVAL);
}
if(rgbflag < 3){
rgbflag ++;
}else{
rgbflag = 1;
}
}