#include "FastLED.h"
#define NUM_LEDS_PER_STRIP 12
CRGB strip1[NUM_LEDS_PER_STRIP];
CRGB strip2[NUM_LEDS_PER_STRIP];
int PWM; //Channel 1 input variable
int p=2;
void setup() {
pinMode(7, INPUT); // Read the pulse width at pin 7
FastLED.addLeds<NEOPIXEL, 10>(strip1, NUM_LEDS_PER_STRIP);
FastLED.addLeds<NEOPIXEL, 11>(strip2, NUM_LEDS_PER_STRIP);
}
void loop() {
PWM = pulseIn(7, HIGH, 25000); // Read the pulse width of channel 1
Serial.print("Channel 1:"); // Print the value of channel 1
Serial.println(PWM); // each channel
if(PWM>=1900 && PWM<=2150)
{
p++;
delay(100);
}
if(p==1)
{
Pattern1(255,0,0,100,1);
Pattern1(0,255,0,100,1);
Pattern1(0,0,255,100,1);
}
if(p==2)
{
Pattern2(255,0,0,100,1);
Pattern2(0,255,0,100,1);
Pattern2(0,0,255,100,1);
}
if(p==3)
{
Pattern3(100);
}
if(p==4)
{
Pattern4(255, 0, 0, 4, 0,0,255,100);
Pattern4(255, 0, 0, 4, 0,255,0,100);
Pattern4(0, 255, 0, 4, 0,100,0,100);
}
if(p==5)
{
Pattern5(3);
}
}
void Pattern1(byte red, byte green, byte blue, int speedDelay, int eye)
{
strip1[10] = CRGB(255, 0, 0);
strip1[11] = CRGB(255, 0, 0);
strip2[10] = CRGB(0, 0, 255);
strip2[11] = CRGB(0, 0, 255);
// First slide the led in one direction
for (int i = 0; i < NUM_LEDS_PER_STRIP-2; i++) {
strip1[i] = CRGB(red, green, blue);
strip2[i] = CRGB(red, green, blue);
for(int j=1; j<=eye;j++)
{strip1[i+j] = CRGB(red, green, blue);
strip2[i+j] = CRGB(red, green, blue);}
// Show the leds
FastLED.show();
// go Back to Black
strip1[i] = CRGB::Black;
strip2[i] = CRGB::Black;
delay(speedDelay);
}
}
void Pattern2(byte red, byte green, byte blue, int speedDelay, int eye)
{
strip1[10] = CRGB(255, 0, 0);
strip1[11] = CRGB(255, 0, 0);
strip2[10] = CRGB(0, 255, 0);
strip2[11] = CRGB(0, 255, 0);
// First slide the led in one direction
for (int i = NUM_LEDS_PER_STRIP-3; i >= 0; i--) {
strip1[i] = CRGB(red, green, blue);
strip2[i] = CRGB(red, green, blue);
for(int j=1; j<=eye;j++)
{strip1[i-j] = CRGB(red, green, blue);
strip2[i-j] = CRGB(red, green, blue);}
// Show the leds
FastLED.show();
// go Back to Black
strip1[i] = CRGB::Black;
strip2[i] = CRGB::Black;
delay(speedDelay);
}
}
void Pattern3(int speedDelay)
{
strip1[10] = CRGB(255, 0, 0);
strip1[11] = CRGB(255, 0, 0);
strip2[10] = CRGB(0, 255, 0);
strip2[11] = CRGB(0, 255, 0);
// First slide the led in one direction
for (int i = 0; i < NUM_LEDS_PER_STRIP-4; i++) {
strip1[i] = CRGB(255, 0, 0);
strip2[i] = CRGB(255, 0, 0);
for(int j=1; j<=1;j++)
{strip1[i+j] = CRGB(0, 0, 255);
strip2[i+j] = CRGB(0, 0, 255);}
for(int k=1; k<=1;k++)
{strip1[i+1+k] = CRGB(0, 255, 0);
strip2[i+1+k] = CRGB(0, 255, 0);}
// Show the leds
FastLED.show();
// go Back to Black
strip1[i] = CRGB::Black;
strip2[i] = CRGB::Black;
strip1[9] = CRGB::Black;
strip2[9] = CRGB::Black;
strip1[8] = CRGB::Black;
strip2[8] = CRGB::Black;
delay(speedDelay);
}
}
void Pattern4(byte red, byte green, byte blue, int postion, byte color1, byte color2, byte color3, int speedDelay)
{
// First slide the led in one direction
for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
strip1[i] = CRGB(color1, color2, color3);
strip2[i] = CRGB(color1, color2, color3);
}
// First slide the led in one direction
for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
strip1[i] = CRGB(red, green, blue);
strip1[i+postion] = CRGB(red, green, blue);
strip2[i] = CRGB(red, green, blue);
strip2[i+postion] = CRGB(red, green, blue);
FastLED.show();
strip1[i] = CRGB(color1, color2, color3);
strip1[i+postion] = CRGB(color1, color2, color3);
strip2[i] = CRGB(color1, color2, color3);
strip2[i+postion] = CRGB(color1, color2, color3);
delay(speedDelay);
}
}
void Pattern5(int pos)
{
// First slide the led in one direction
for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
strip1[i] = CRGB::White;
strip2[i] = CRGB::White;
}
// First slide the led in one direction
for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
strip1[i] = CRGB(i*20,0,0);
strip1[i+pos] = CRGB(i*20,0,0);
strip2[i] = CRGB(i*20,0,0);
strip2[i+pos] = CRGB(i*20,0,0);
FastLED.show();
strip1[i] = CRGB::White;
strip1[i+pos] = CRGB::White;
strip2[i] = CRGB::White;
strip2[i+pos] = CRGB::White;
FastLED.setBrightness(i*20);
delay(100);
}
}