/*
PAB49162 Wokwi projets
https://wokwi.com/makers/pab49162
WLED multi-strip support
https://kno.wled.ge/features/multi-strip/
Multiple controller examples
https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples
Strip effects for NeoPixel and FastLED
https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
RGB color code chart
https://www.rapidtables.com/web/color/RGB_Color.html
NeoMatrix setup guide
https://learn.adafruit.com/adafruit-neopixel-uberguide/neomatrix-library
Microphone INMP441 I2S Omnidirectional Module
https://techmaze.romman.store/product/99189039$0
*/
#include "FastLED.h"
#define NUM_LEDS 24
CRGB leds1[NUM_LEDS];
CRGB leds2[NUM_LEDS];
#define LED_TYPE WS2812
#define LEDS1PIN 35
#define LEDS2PIN 32
#define COLOR_ORDER BRG
#define BRIGHTNESS 255
void setup()
{
Serial.begin(9600);
FastLED.addLeds<LED_TYPE, LEDS1PIN, COLOR_ORDER>(leds1, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, LEDS2PIN, COLOR_ORDER>(leds2, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}
void loop() {
byte red,blue,green;
for (int i = 0; i <= 4; i++) {
//(i) is the number of different colors that will rotate through
switch (i) {
case 0:
Serial.println("Color is burnt orange");
red = 0xff; green = 0x45; blue = 0x0; // color is burnt orange
break;
case 1:
Serial.println("Color is red");
red = 0xff; green = 0x0; blue = 0x0; // color is red
break;
case 2:
Serial.println("Color is blue");
red = 0x0; green = 0x0; blue = 0xff; // color is blue
break;
case 3:
Serial.println("Color is green");
red = 0x0; green = 0xff; blue = 0x0; // color is green
break;
case 4:
Serial.println("Color is yellow");
red = 0xff; green = 0xff; blue = 0x0; // color is yellow
break;
default:
Serial.println("Error - unexpected value of i");
break;
}
for (int j = 0; j <= 5; j++) {
//(j) is the number of times the color will flash before changing to the next color
Serial.println(j);
colorStrip(red, blue, green, 200);
Sparkle(red, blue, green, 200);
}
}
}
void Sparkle(byte red, byte green, byte blue, int SpeedDelay) {
int Pixel = random(NUM_LEDS);
Serial.print("Pixel value is ");
Serial.println(Pixel);
setPixel1(Pixel,red,green,blue);
showStrip();
delay(SpeedDelay);
setPixel1(Pixel,0,0,0);
}
void colorStrip(byte red, byte green, byte blue, int SpeedDelay) {
for(uint16_t i=0; i<NUM_LEDS; i++) {
setPixel2(i, red, green, blue);
showStrip();
}
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel1(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// FastLED
leds1[Pixel].r = red;
leds1[Pixel].g = green;
leds1[Pixel].b = blue;
#endif
}
void setPixel2(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// FastLED
leds2[Pixel].r = red;
leds2[Pixel].g = green;
leds2[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel1(i, red, green, blue);
}
showStrip();
}