I am having trouble with the front gun light. The begining of my code works for the Engine flicker, and the bridge lights.
when i tried to add code for the pull down switch to detect firing of the gun, everything goes wrong.
the gun lights, then goes thru its delay, interrupting the engine flicker, and they just bounce back and forth.
the gun lights, delay, the engine led's flicker once, then back to the gun light again.
Im a bit lost and still learning, any help would be appreciated.
Thanks
Code: Select all
/*
Argo Lights
Bridge - Green X2 on Pin 4
Engines- Red X3 on Pin 5
Gun - White X1 on Pin 3
*/
int gunled = 3; // Gun Led Connected to pin 3
int guntrig = 7; // Gun switch connected to pin 7
void setup() {
// initialize the digital pin as an output or input
pinMode(7, INPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
}
void loop(){
digitalWrite(5, HIGH); // set the LED on
delay(50); // wait
digitalWrite(5, LOW); // set the LED off Flicker for engine lights
delay(20); // wait
digitalWrite(4, HIGH); // Bridge lights always on
digitalRead(guntrig); // Read trigger button for fire sequence
if (guntrig == HIGH);
analogWrite(gunled, 255);
delay(2000);
for(int fade = 255; fade>= 0; fade -=5)
analogWrite(gunled, fade);
delay(30);
}