#include <FastLED.h> //led
//---------------------------LED------------------------------------
#define LED_TYPE WS2812B // define the led type
#define NUM_STRIPS 1 // number of led strips
#define NUM_LEDS_PER_STRIP 8 // total number of leds per strip
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
const long LEDinterval = 1000;
unsigned long LEDpreviousMillis = 0;
int ledState =LOW;
int left;
int hazzard;
int right;
int brake;
int brightness;
void setup() {
Serial.begin(115200);
//---------------fastLED-----------------------------------------------------
FastLED.addLeds<NEOPIXEL, 2>(leds[0], NUM_LEDS_PER_STRIP); //define the pin output for led strip one
fill_solid(leds[0], NUM_LEDS_PER_STRIP, CRGB::Black); // some led strips are all on at power on, so let's power them off at boot
FastLED.show();
}
void loop()
{
int BT_data_action(int id, int value)
{
if (id ==1 && value ==1)
{
if(left == 1 || hazzard ==1 || right ==1)
{
left=0;
hazzard=0;
right=0;
}
else{
left =1;
}
}
if (id ==2 && value ==1)
{
if(left == 1 || hazzard ==1 || right ==1)
{
left=0;
hazzard=0;
right=0;
}
else{
hazzard =1;
}
}
if (id ==3 && value ==1)
{
if(left == 1 || hazzard ==1 || right ==1)
{
left=0;
hazzard=0;
right=0;
}
else{
right =1;
}
}
}
void send_to_BT()
{
unsigned long LEDcurrentMillis = millis();
if (LEDcurrentMillis - LEDpreviousMillis >= LEDinterval)
{
// save the last time you blinked the LED
LEDpreviousMillis = LEDcurrentMillis;
if (ledState == LOW) {
ledState = HIGH;
fill_gradient(leds[0],3,CHSV( 0, 0, 255),4,CHSV( 0, 0, 255));
FastLED.show();
// LSB
} else {
ledState = LOW;
fill_gradient(leds[0],3,CHSV( 0, 0, 0),4,CHSV( 0, 0, 0));
FastLED.show();
}
}
}
void NEOPIXLE()
{
if (left ==1)
{
// for(int pixel = 4; pixel < 7; pixel++)
// {
leds[0][0] = CHSV( 0, 255, 150);
leds[0][1] = CHSV( 0, 255, 150);
leds[0][2] = CHSV( 0, 255, 150);
// }
FastLED.show();
}
if (left ==0)
{
//for(int pixel = 4; pixel < 7; pixel++)
//{
// leds[0][pixel] = CHSV( 0, 0, 0);
leds[0][0] = CHSV( 0, 0, 0);
leds[0][1] = CHSV( 0, 0, 0);
leds[0][2] = CHSV( 0, 0, 0);
// }
FastLED.show();
}
//------------------------------hazzard------------------------------------------------
if(hazzard == 1){
fill_gradient(leds[0],3,CHSV( 0, 0, 255),4,CHSV( 0, 0, 255));
FastLED.show();
}
if(hazzard == 0 && ledState ==0){
fill_gradient(leds[0],3,CHSV( 0, 0, 0),4,CHSV( 0, 0, 0));
FastLED.show();
}
}