/*
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 <Adafruit_NeoPixel.h>
#define PINA 22
#define PINB 23
#define NUM_LEDS 4
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripA = Adafruit_NeoPixel(NUM_LEDS, PINA, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripB = Adafruit_NeoPixel(NUM_LEDS, PINB, NEO_GRB + NEO_KHZ800);
void setup() {
stripA.begin();
stripA.show(); // Initialize all pixels to 'off'
stripB.begin();
stripB.show(); // Initialize all pixels to 'off'
}
void loop() {
FadeInOutA(0xff, 0x00, 0x00); // red
FadeInOutA(0xff, 0xff, 0xff); // white
FadeInOutA(0x00, 0x00, 0xff); // blue
FadeInOutB(0xff, 0x5a, 0x00); // burnt orange
FadeInOutB(0xff, 0xff, 0xff); // white
showStripA();
showStripB();
}
void FadeInOutA(byte red, byte green, byte blue){
float r, g, b;
for(int k = 0; k < 256; k=k+1) {
r = (k/256.0)*red;
g = (k/256.0)*green;
b = (k/256.0)*blue;
setAllA(r,g,b);
showStripA();
}
for(int k = 255; k >= 0; k=k-2) {
r = (k/256.0)*red;
g = (k/256.0)*green;
b = (k/256.0)*blue;
setAllA(r,g,b);
showStripA();
delay(5);
}
}
void FadeInOutB(byte red, byte green, byte blue){
float r, g, b;
for(int k = 0; k < 256; k=k+1) {
r = (k/256.0)*red;
g = (k/256.0)*green;
b = (k/256.0)*blue;
setAllB(r,g,b);
showStripB();
}
for(int k = 255; k >= 0; k=k-2) {
r = (k/256.0)*red;
g = (k/256.0)*green;
b = (k/256.0)*blue;
setAllB(r,g,b);
showStripB();
delay(5);
}
}
void showStripA() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
stripA.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void showStripB() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
stripB.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixelA(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
stripA.setPixelColor(Pixel, stripA.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setPixelB(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
stripB.setPixelColor(Pixel, stripB.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAllA(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixelA(i, red, green, blue);
}
//showStripA();
}
void setAllB(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixelB(i, red, green, blue);
}
//showStripB();
}