#include <FastLED.h>
#define pinRGB 6
#define qtyRGB 23
int pinMouth = A0; // pin for mouth sensor (A0)
int iMouth = 0; // int for reading from pin input
int iTrigger = 1023/2; // value to trigger event
CRGB leds[qtyRGB];
CRGB rgbLure = CRGB(150,0,255);
CRGB rgbEyeL = CRGB(0,0,255);
CRGB rgbEyeR = CRGB(0,0,255);
void setup() {
delay(1000);
FastLED.addLeds<WS2812B, pinRGB, GRB>(leds, qtyRGB).setCorrection(TypicalLEDStrip); //initialises LED strip
FastLED.setBrightness(255); //global brightness
}
void loop() {
leds[0] = rgbLure; // lure colour
leds[1] = rgbEyeL; // left-eye colour
leds[2] = rgbEyeR; // right-eye colour
FastLED.show();
iMouth = analogRead(pinMouth);
if (iMouth >= iTrigger){
activateLightStrip();
}
else {
deactivateLightStrip();
}
}
void activateLightStrip(){
for (int i = 3; i <= 12; i++){
leds[i] = CRGB(100, 150, 255);
leds[i+10] = CRGB(100, 150, 255);
FastLED.show();
delay(200);
}
}
void deactivateLightStrip(){
for (int i = 12; i >= 3; i--){
leds[i] = CRGB(0, 0, 0);
leds[i+10] = CRGB(0, 0, 0);
FastLED.show();
delay(30);
}
}