I decided to try revamping my car headlights with arduino nano and ws2812.
Previous attemptsI started welding a lot a single leds to make a matrix.
But unfortunately this didin't work, the comunication bus suffer from too much hand made weldings.
I decided to buy led strips that have capacitor on each led.
Additionals car wiringI started making new wiring identical to the old one so I i want I can mount traditional headlamps too.
I added some signals to increase the brightness of the headlights if low-beam or high-beam are on, I also added a relay and a signal to power the arduinos only when the car is on.
I don't feel confident that led strip welded to a pcb can resist to hurts and vibrations for a long amount of time, i'll keep you updated if something stop working.
PCB SchematicThe schematic is simple, we just need a voltage divider for each digital input and a DC-DC to power the arduino ( Traco TSR_2-2450 I paid 15$ for each DC-DC what else could I use? I wanted something reliable).
I bought a led strip on Aliexpress and now I manage to make it work.
I bough 2 strips on differents months(sameplace) and the make different colors! I had to adjust the code to hide this but the white is still not identical
I feel satisfied with the result, certainly could have been done better but it works.
Was even the first time that I order a custom PCB,
CODEI attach the code to this repository but I don't want to comment it, is written very bad, is not clear at all, but if someone want take a look it is in the attached files.
Headlight firmware
C/C++But it works,
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define LED_PIN 6 //pin data connected to led strip
#define LED_COUNT 60 //total led number
#define BRIGHTNESS 255 // NeoPixel brightness, 0 (min) to 255 (max)
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); // Declare our NeoPixel strip object:
unsigned long Millis = 0;
//variabili per Startup
int i=0;//numero di volte che viene ripetuto il loop nella procedura di startup
int RStart =0;
int GStart =0;
int BStart =0;
int delayStart =7;
//variables for KITT mode
int KITTstack = 0;
int KITTSTATUS = 0;
unsigned long lastKITT=0;
int KITTtime=1;
int KITTfade=0;
int KITTrev=0;
//variables for POLICE mode
int POLICEstack = 0;
int POLICESTATUS = 0;
int POLICEtime = 1000;
int POLICEsequence = 1;
unsigned long lastPOLICE = 0;
int REMOVEstackT=30000;
unsigned long LastREMOVE=0;
unsigned long lastupdate=0;
unsigned long TriggerTime = 0; //time passed from the HIGH input
int debounceDIRLIGHT=0;
unsigned long lastdebounceDIRLIGHT=0;
bool Arrow = 0; //is 1 when the input become HIGH
int debounceRUNLIGHT=0;
unsigned long lastdebounceRUNLIGHT=0;
bool RUNLIGHTSTATUS=0;
int debounceLOWLIGHT=0;
unsigned long lastdebounceLOWLIGHT=0;
bool LOWLIGHTSTATUS=0;
int debounceHIGHLIGHT=0;
unsigned long lastdebounceHIGHLIGHT=0;
bool HIGHLIGHTSTATUS=0;
int DIRLIGHTPIN = 5;
int RUNLIGHTPIN = 7;
int LOWLIGHTPIN = 9;
int HIGHLIGHTPIN = 10;
int ROUT = 0;
int GOUT = 0;
int BOUT = 0;
//modifiers to obtain warm white
float RWW =1;
float GWW =0.94;
float BWW =0.88;
//USER SETTING
int CycleTime= 300; //ms of the animation of direction light
float ArrowBRI=0.5; //arrow brightness 1=100% 0.4 = 40% ect ect
float RunningBRI=0.2; //running lights brightness 1=100% 0.4 = 40% ect ect
float LowBeamBRI=0.3; //running lights brightness 1=100% 0.4 = 40% ect ect
float HighBeamBRI=0.5; //running lights brightness 1=100% 0.4 = 40% ect ect
bool WarmWhite = 0;
void setup()
{
pinMode(5,INPUT); // Direction light signal pin
pinMode(7,INPUT); // Direction light signal pin
pinMode(9,INPUT); // Direction light signal pin
pinMode(10,INPUT); // Direction light signal pin
pinMode(6,OUTPUT);
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
Serial.begin(9600); //DEBUG FUNCTION ONLY
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255)
Startup();
}
void loop() {
Millis= millis();
if (KITTstack==10)//if i reach x stacks i activate the KITTMODE mode
{
KITTSTATUS = !KITTSTATUS;
POLICESTATUS=0;
KITTstack =0;
}
if (POLICEstack==10)//if i reach x stacks i activate the POLICE mode
{
POLICESTATUS=!POLICESTATUS;
POLICEstack=0;
KITTSTATUS = 0;
}
if (KITTSTATUS==1) //if is 1 police status is on
{
KITT(); //updating leds for police mode
}
if (POLICESTATUS==1) //if is 1 police status is on
{
POLICE(); //updating leds for police mode
}
if ((KITTSTATUS==0)&(POLICESTATUS==0))
{
Dirlight(); //updating leds for direction lights
}
if ((Millis-LastREMOVE)>3000)// removing one stack every x millis
{
if (KITTstack>0)
{
KITTstack--;
}
if (POLICEstack>0)
{
POLICEstack--;
}
LastREMOVE=Millis;
}
if ((Millis-lastupdate)>1)// updating led states arduino nano too slow to keep this commands in the loop
{
strip.show();
lastupdate=Millis;
}
if (WarmWhite == 1)
{
RWW = 100;
GWW = 94;
BWW = 88;
}
else
RWW = 1;
GWW = 1;
BWW = 1;
if (Arrow==1)
{
ROUT = 0;
GOUT = 0;
BOUT = 0;
}
if ((RUNLIGHTSTATUS==0)&(Arrow==0)&(POLICESTATUS==0)&(KITTSTATUS==0))
{
ROUT = 0;
GOUT = 0;
BOUT = 0;
}
//--------------------change white leds status depends on inputs
if ((RUNLIGHTSTATUS==1)&(Arrow==0)&(LOWLIGHTSTATUS==0)&(POLICESTATUS==0)&(KITTSTATUS==0)&((Millis-TriggerTime)>(CycleTime*5)))
//why ((Millis-TriggerTime)>(CycleTime*5)) ?? Because i don't want the carlight flash white between arrow animations
{
ROUT = (RunningBRI*255);
GOUT = (RunningBRI*255);
BOUT = (RunningBRI*255);
}
if ((RUNLIGHTSTATUS==1)&(LOWLIGHTSTATUS==1)&(HIGHLIGHTSTATUS==0)&(POLICESTATUS==0)&(KITTSTATUS==0)&(Arrow==0)&((Millis-TriggerTime)>(CycleTime*5)))
//why ((Millis-TriggerTime)>(CycleTime*5)) ?? Because i don't want the carlight flash white between arrow animations
{
ROUT = (LowBeamBRI*255);
GOUT = (LowBeamBRI*255);
BOUT = (LowBeamBRI*255);
}
if ((RUNLIGHTSTATUS==1)&(LOWLIGHTSTATUS==1)&(HIGHLIGHTSTATUS==1)&(POLICESTATUS==0)&(KITTSTATUS==0)&(Arrow==0)&((Millis-TriggerTime)>(CycleTime*5)))
//why ((Millis-TriggerTime)>(CycleTime*5)) ?? Because i don't want the carlight flash white between arrow animations
{
ROUT = (HighBeamBRI*255);
GOUT = (HighBeamBRI*255);
BOUT = (HighBeamBRI*255);
}
if ((Millis-lastdebounceDIRLIGHT)>2)// debouncing the input DIRLIGHT
{
if ((digitalRead(DIRLIGHTPIN)==1)&(debounceDIRLIGHT<40))
{
debounceDIRLIGHT++;
if (debounceDIRLIGHT==10)
{
Arrow=1;
POLICESTATUS=0;
KITTSTATUS=0;
TriggerTime=Millis;
}
}
if ((digitalRead(DIRLIGHTPIN)==0)&(debounceDIRLIGHT>0))
{
debounceDIRLIGHT--;
if (debounceDIRLIGHT<2)
{
Arrow=0;
}
}
lastdebounceDIRLIGHT=Millis;
}
if ((Millis-lastdebounceRUNLIGHT)>2)// debouncing the input RUNLIGHT
{
if ((digitalRead(RUNLIGHTPIN)==1)&(debounceRUNLIGHT<101))
{
debounceRUNLIGHT++;
if (debounceRUNLIGHT==20)
{
RUNLIGHTSTATUS=1;
}
}
if ((digitalRead(RUNLIGHTPIN)==0)&(debounceRUNLIGHT>0))
{
debounceRUNLIGHT--;
if (debounceRUNLIGHT<2)
{
RUNLIGHTSTATUS=0;
}
}
lastdebounceRUNLIGHT=Millis;
}
if ((Millis-lastdebounceLOWLIGHT)>1)// debouncing the input LOWLIGHT
{
if ((digitalRead(LOWLIGHTPIN)==1)&(debounceLOWLIGHT<30))
{
debounceLOWLIGHT++;
if (debounceLOWLIGHT==20)
{
LOWLIGHTSTATUS=1;
KITTstack++;
Serial.println(KITTSTATUS); //debug remove later
Serial.println(KITTstack);
}
}
if ((digitalRead(LOWLIGHTPIN)==0)&(debounceLOWLIGHT>0))
{
debounceLOWLIGHT--;
if (debounceLOWLIGHT<2)
{
LOWLIGHTSTATUS=0;
}
}
lastdebounceLOWLIGHT=Millis;
}
if ((Millis-lastdebounceHIGHLIGHT)>2)// debouncing the input RUNLIGHT
{
if ((digitalRead(HIGHLIGHTPIN)==1)&(debounceHIGHLIGHT<101))
{
debounceHIGHLIGHT++;
if (debounceHIGHLIGHT==20)
{
HIGHLIGHTSTATUS=1;
POLICEstack++;
}
}
if ((digitalRead(HIGHLIGHTPIN)==0)&(debounceHIGHLIGHT>0))
{
debounceHIGHLIGHT--;
if (debounceHIGHLIGHT<2)
{
HIGHLIGHTSTATUS=0;
}
}
lastdebounceHIGHLIGHT=Millis;
}
}
void Dirlight() //direction light function
{
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.05))
{
strip.setPixelColor(0, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(39, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(40, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(0, ROUT, GOUT, BOUT);
strip.setPixelColor(39, ROUT, GOUT, BOUT);
strip.setPixelColor(40, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.10))
{
strip.setPixelColor(1, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(38, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(41, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(1, ROUT, GOUT, BOUT);
strip.setPixelColor(38, ROUT, GOUT, BOUT);
strip.setPixelColor(41, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.15))
{
strip.setPixelColor(2, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(37, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(42, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(2,ROUT, GOUT, BOUT);
strip.setPixelColor(37, ROUT, GOUT, BOUT);
strip.setPixelColor(42, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.20))
{
strip.setPixelColor(3, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(36, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(43, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(3, ROUT, GOUT, BOUT);
strip.setPixelColor(36, ROUT, GOUT, BOUT);
strip.setPixelColor(43, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.25))
{
strip.setPixelColor(4, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(35, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(44, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(4, ROUT, GOUT, BOUT);
strip.setPixelColor(35, ROUT, GOUT, BOUT);
strip.setPixelColor(44, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.30))
{
strip.setPixelColor(5, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(34, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(45, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(5, ROUT, GOUT, BOUT);
strip.setPixelColor(34, ROUT, GOUT, BOUT);
strip.setPixelColor(45, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.35))
{
strip.setPixelColor(6, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(33, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(46, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(6, ROUT, GOUT, BOUT);
strip.setPixelColor(33, ROUT, GOUT, BOUT);
strip.setPixelColor(46, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.40))
{
strip.setPixelColor(7, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(32, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(47, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(7, ROUT, GOUT, BOUT);
strip.setPixelColor(32, ROUT, GOUT, BOUT);
strip.setPixelColor(47, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.45))
{
strip.setPixelColor(8, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(31, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(48, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(8, ROUT, GOUT, BOUT);
strip.setPixelColor(31, ROUT, GOUT, BOUT);
strip.setPixelColor(48, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.50))
{
strip.setPixelColor(9, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(30, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(49, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(9, ROUT, GOUT, BOUT);
strip.setPixelColor(30, ROUT, GOUT, BOUT);
strip.setPixelColor(49, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.55))
{
strip.setPixelColor(10, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(29, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(50, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(10, ROUT, GOUT, BOUT);
strip.setPixelColor(29, ROUT, GOUT, BOUT);
strip.setPixelColor(50, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.60))
{
strip.setPixelColor(11, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(28, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(51, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(11, ROUT, GOUT, BOUT);
strip.setPixelColor(28, ROUT, GOUT, BOUT);
strip.setPixelColor(51, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.65))
{
strip.setPixelColor(12, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(27, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(52, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(12, ROUT, GOUT, BOUT);
strip.setPixelColor(27, ROUT, GOUT, BOUT);
strip.setPixelColor(52, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.70))
{
strip.setPixelColor(13, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(26, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(53, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(13, ROUT, GOUT, BOUT);
strip.setPixelColor(26, ROUT, GOUT, BOUT);
strip.setPixelColor(53, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.75))
{
strip.setPixelColor(14, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(25, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(54, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(14, ROUT, GOUT, BOUT);
strip.setPixelColor(25, ROUT, GOUT, BOUT);
strip.setPixelColor(54, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.80))
{
strip.setPixelColor(15, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(24, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(55, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(15, ROUT, GOUT, BOUT);
strip.setPixelColor(24, ROUT, GOUT, BOUT);
strip.setPixelColor(55, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.85))
{
strip.setPixelColor(16, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(23, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(56, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(16, ROUT, GOUT, BOUT);
strip.setPixelColor(23, ROUT, GOUT, BOUT);
strip.setPixelColor(56, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.90))
{
strip.setPixelColor(17, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(22, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(57, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(17, ROUT, GOUT, BOUT);
strip.setPixelColor(22, ROUT, GOUT, BOUT);
strip.setPixelColor(57, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*0.95))
{
strip.setPixelColor(18, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(21, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(58, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(18, ROUT, GOUT, BOUT);
strip.setPixelColor(21, ROUT, GOUT, BOUT);
strip.setPixelColor(58, ROUT, GOUT, BOUT);
}
if ((Arrow==1)&(Millis-TriggerTime)>(CycleTime*1))
{
strip.setPixelColor(19, (255*ArrowBRI), (40*ArrowBRI), 0);
strip.setPixelColor(20, (255*ArrowBRI),(40*ArrowBRI), 0);
strip.setPixelColor(59, (255*ArrowBRI),(40*ArrowBRI), 0);
}
else
{
strip.setPixelColor(19, ROUT, GOUT, BOUT);
strip.setPixelColor(20, ROUT, GOUT, BOUT);
strip.setPixelColor(59, ROUT, GOUT, BOUT);
}
}
//PROCEDURA STARTUP //////////////////////////////////////////////////////////////////////////////////////
void Startup()
{
//fine ciclo for startup
RStart=255;
strip.setPixelColor(29, RStart, 0, BStart);
strip.setPixelColor(30, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(28, RStart, 0, BStart);
strip.setPixelColor(31, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(27, RStart, 0, BStart);
strip.setPixelColor(32, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(26, RStart, 0, BStart);
strip.setPixelColor(33, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(25, RStart, 0, BStart);
strip.setPixelColor(34, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(24, RStart, 0, BStart);
strip.setPixelColor(35, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(23, RStart, 0, BStart);
strip.setPixelColor(36, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(22, RStart, 0, BStart);
strip.setPixelColor(37, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(21, RStart, 0, BStart);
strip.setPixelColor(38, RStart, 0, BStart);
strip.show();
delay (100);
strip.setPixelColor(20, RStart, 0, BStart);
strip.setPixelColor(39, RStart, 0, BStart);
strip.show();
delay (100);
}
void POLICE()
{
if ((Millis-lastPOLICE)>POLICEtime)//every POLICETIME
{ Serial.println("TASKPOLICE");
POLICEsequence++;
if(POLICEsequence==6)
{
POLICEsequence=1;
}
if (POLICEsequence==1)
{
for (i=0;i<61;i++)
{
strip.setPixelColor((i), 0, 0, 255);
POLICEtime=400;
}
}
if (POLICEsequence==2)
{
for (i=0;i<61;i++)
{
strip.setPixelColor((i), 255, 0, 0 );
POLICEtime=300;
}
}
if (POLICEsequence==3)
{
for (i=0;i<61;i++)
{
strip.setPixelColor((i), 0, 0, 255);
POLICEtime=150;
}
}
if (POLICEsequence==4)
{
for (i=0;i<61;i++)
{
strip.setPixelColor((i), 255, 0, 0);
POLICEtime=600;
}
}
if (POLICEsequence==5)
{
for (i=0;i<61;i++)
{
strip.setPixelColor((i), 0, 0, 255);
POLICEtime=450;
}
}
lastPOLICE=Millis;
strip.show();
}
}
void KITT()
{
if ((Millis-lastKITT)>KITTtime)//every KITTTIME
{ Serial.println("MAICOL"); //debug remove later
Serial.println(KITTfade); //debug remove later
Serial.println(KITTrev); //debug remove later
if (KITTfade==0)
{
KITTrev=0;
}
if (KITTfade==1400)
{
KITTrev=1;
}
if (KITTrev==0)
{
KITTfade=(KITTfade+5);
}
if (KITTrev==1)
{
KITTfade=(KITTfade-5);
}
if (((KITTfade-0)<255)&((KITTfade-0)>0))
{
strip.setPixelColor(0, KITTfade, 0, 0);
strip.setPixelColor(39, KITTfade, 0, 0);
strip.setPixelColor(40, KITTfade, 0, 0);
}
else
{
strip.setPixelColor(0, 0, 0, 0);
strip.setPixelColor(39, 0, 0, 0);
strip.setPixelColor(40, 0, 0, 0);
}
if (((KITTfade-60)<255)&((KITTfade-60)>0))
{
strip.setPixelColor(1, (KITTfade-60), 0, 0);
strip.setPixelColor(38, (KITTfade-60), 0, 0);
strip.setPixelColor(41, (KITTfade-60), 0, 0);
}
else
{
strip.setPixelColor(1, 0, 0, 0);
strip.setPixelColor(38,0, 0, 0);
strip.setPixelColor(41,0, 0, 0);
}
if (((KITTfade-120)<255)&((KITTfade-120)>0))
{
strip.setPixelColor(2, (KITTfade-120), 0, 0);
strip.setPixelColor(37, (KITTfade-120), 0, 0);
strip.setPixelColor(42, (KITTfade-120), 0, 0);
}
else
{
strip.setPixelColor(2, 0, 0, 0);
strip.setPixelColor(37, 0, 0, 0);
strip.setPixelColor(42, 0, 0, 0);
}
if (((KITTfade-180)<255)&((KITTfade-180)>0))
{
strip.setPixelColor(3, (KITTfade-180), 0, 0);
strip.setPixelColor(36, (KITTfade-180), 0, 0);
strip.setPixelColor(43, (KITTfade-180), 0, 0);
}
else
{
strip.setPixelColor(3, 0, 0, 0);
strip.setPixelColor(36, 0, 0, 0);
strip.setPixelColor(43, 0, 0, 0);
}
if (((KITTfade-240)<255)&((KITTfade-240)>0))
{
strip.setPixelColor(4, (KITTfade-240), 0, 0);
strip.setPixelColor(35, (KITTfade-240), 0, 0);
strip.setPixelColor(44, (KITTfade-240), 0, 0);
}
else
{
strip.setPixelColor(4, 0, 0, 0);
strip.setPixelColor(35, 0, 0, 0);
strip.setPixelColor(44, 0, 0, 0);
}
if (((KITTfade-300)<255)&((KITTfade-300)>0))
{
strip.setPixelColor(5, (KITTfade-300), 0, 0);
strip.setPixelColor(34, (KITTfade-300), 0, 0);
strip.setPixelColor(45, (KITTfade-300), 0, 0);
}
else
{
strip.setPixelColor(5, 0, 0, 0);
strip.setPixelColor(34, 0, 0, 0);
strip.setPixelColor(45, 0, 0, 0);
}
if (((KITTfade-360)<255)&((KITTfade-360)>0))
{
strip.setPixelColor(6, (KITTfade-360), 0, 0);
strip.setPixelColor(33, (KITTfade-360), 0, 0);
strip.setPixelColor(46, (KITTfade-360), 0, 0);
}
else
{
strip.setPixelColor(6,0, 0, 0);
strip.setPixelColor(33, 0, 0, 0);
strip.setPixelColor(46, 0, 0, 0);
}
if (((KITTfade-420)<255)&((KITTfade-420)>0))
{
strip.setPixelColor(7, (KITTfade-420), 0, 0);
strip.setPixelColor(32, (KITTfade-420), 0, 0);
strip.setPixelColor(47, (KITTfade-420), 0, 0);
}
else
{
strip.setPixelColor(7, 0, 0, 0);
strip.setPixelColor(32, 0, 0, 0);
strip.setPixelColor(47, 0, 0, 0);
}
if (((KITTfade-480)<255)&((KITTfade-480)>0))
{
strip.setPixelColor(8, (KITTfade-480), 0, 0);
strip.setPixelColor(31, (KITTfade-480), 0, 0);
strip.setPixelColor(48, (KITTfade-480), 0, 0);
}
else
{
strip.setPixelColor(8, 0, 0, 0);
strip.setPixelColor(31, 0, 0, 0);
strip.setPixelColor(48, 0, 0, 0);
}
if (((KITTfade-540)<255)&((KITTfade-540)>0))
{
strip.setPixelColor(9, (KITTfade-540), 0, 0);
strip.setPixelColor(30, (KITTfade-540), 0, 0);
strip.setPixelColor(49, (KITTfade-540), 0, 0);
}
else
{
strip.setPixelColor(9, 0, 0, 0);
strip.setPixelColor(30, 0, 0, 0);
strip.setPixelColor(49, 0, 0, 0);
}
if (((KITTfade-600)<255)&((KITTfade-600)>0))
{
strip.setPixelColor(10,(KITTfade-600), 0, 0);
strip.setPixelColor(29, (KITTfade-600), 0, 0);
strip.setPixelColor(50, (KITTfade-600), 0, 0);
}
else
{
strip.setPixelColor(10, 0, 0, 0);
strip.setPixelColor(29, 0, 0, 0);
strip.setPixelColor(50, 0, 0, 0);
}
if (((KITTfade-660)<255)&((KITTfade-660)>0))
{
strip.setPixelColor(11, (KITTfade-660), 0, 0);
strip.setPixelColor(28, (KITTfade-660), 0, 0);
strip.setPixelColor(51, (KITTfade-660), 0, 0);
}
else
{
strip.setPixelColor(11, 0, 0, 0);
strip.setPixelColor(28, 0, 0, 0);
strip.setPixelColor(51, 0, 0, 0);
}
if (((KITTfade-720)<255)&((KITTfade-720)>0))
{
strip.setPixelColor(12, (KITTfade-720), 0, 0);
strip.setPixelColor(27, (KITTfade-720), 0, 0);
strip.setPixelColor(52, (KITTfade-720), 0, 0);
}
else
{
strip.setPixelColor(12, 0, 0, 0);
strip.setPixelColor(27, 0, 0, 0);
strip.setPixelColor(52, 0, 0, 0);
}
if (((KITTfade-780)<255)&((KITTfade-780)>0))
{
strip.setPixelColor(13, (KITTfade-780), 0, 0);
strip.setPixelColor(26, (KITTfade-780), 0, 0);
strip.setPixelColor(53, (KITTfade-780), 0, 0);
}
else
{
strip.setPixelColor(13, 0, 0, 0);
strip.setPixelColor(26, 0, 0, 0);
strip.setPixelColor(53, 0, 0, 0);
}
if (((KITTfade-840)<255)&((KITTfade-840)>0))
{
strip.setPixelColor(14, (KITTfade-840), 0, 0);
strip.setPixelColor(25, (KITTfade-840), 0, 0);
strip.setPixelColor(54, (KITTfade-840), 0, 0);
}
else
{
strip.setPixelColor(14, 0, 0, 0);
strip.setPixelColor(25, 0, 0, 0);
strip.setPixelColor(54, 0, 0, 0);
}
if (((KITTfade-900)<255)&((KITTfade-900)>0))
{
strip.setPixelColor(15, (KITTfade-900), 0, 0);
strip.setPixelColor(24, (KITTfade-900), 0, 0);
strip.setPixelColor(55, (KITTfade-900), 0, 0);
}
else
{
strip.setPixelColor(15, 0, 0, 0);
strip.setPixelColor(24, 0, 0, 0);
strip.setPixelColor(55, 0, 0, 0);
}
if (((KITTfade-960)<255)&((KITTfade-960)>0))
{
strip.setPixelColor(16, (KITTfade-960), 0, 0);
strip.setPixelColor(23, (KITTfade-960), 0, 0);
strip.setPixelColor(56, (KITTfade-960), 0, 0);
}
else
{
strip.setPixelColor(16, 0, 0, 0);
strip.setPixelColor(23, 0, 0, 0);
strip.setPixelColor(56, 0, 0, 0);
}
if (((KITTfade-1020)<255)&((KITTfade-1020)>0))
{
strip.setPixelColor(17, (KITTfade-1020), 0, 0);
strip.setPixelColor(22, (KITTfade-1020), 0, 0);
strip.setPixelColor(57, (KITTfade-1020), 0, 0);
}
else
{
...
This file has been truncated, please download it to see its full contents.
Comments
Please log in or sign up to comment.