Beginner here so any help is appreciated.
Looking for advice on how to simulate one of the green lights to blink acting as a green turn signal then solidify to signify regular green light then continue its sequence.
Also trying to add a button to act as a sensor so it reads there is a "car" there and turns any signal green.
Thought I could just add
delay(1000);
digitalWrite(4,0);
delay(500);
digitalWrite(4,1);
delay(500);
digitalWrite(4,0);
delay(500);
because 4 is one of the green lights pins but then it cuts all the other red lights off, so i added the little bit of code below but it was turning all the lights on iffy i just want the green light to blink while red lights remain on that way it sort of signifys a green left turn light.
digitalWrite(8, 1);
digitalWrite(5, 1);
digitalWrite(2, 1);
digitalWrite(13, 1);
2,7,10,13 are red led pins
3,6,9,12 are yellow led pins
4,5,11,8 are the green led pins
I created a sequence that will work for me to signify a left turn signal.. only thing I can do to make it better is make that Led flash during its delay..
Main thing I need to do is create a button that shortens the delay of a red light sequence that way it acts as a sensor and tells it a car is there. if that makes sense.. basically i need to make it where I can press a button and the delay shortens on the current red light...
Heres the new sequence I also updated it above.
<
void setup() {
// put your setup code here, to run once:
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT); //defining pins as output
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//when program starts right green and left green should be ON and up Red and down red should be on so
digitalWrite(3,0); //yellow LEDs
digitalWrite(6,0);
digitalWrite(9,0);
digitalWrite(12,0);
digitalWrite(4,1);
digitalWrite(10,1);
digitalWrite(13,1);
digitalWrite(7,1); //now we have to give some delay
delay(5000);
//now all the yellow lights should be ON and all the previous LED should be off so
digitalWrite(13,0);
digitalWrite(4,0);
digitalWrite(10,0);
digitalWrite(7,0);
digitalWrite(3,1); //yellow LEDs
digitalWrite(6,1);
digitalWrite(9,1);
digitalWrite(12,1);
//again some delay for yellow LEds
delay(1000);
//now we have to turn off all the yellow leds and we have to turn on the up down green and right left red so
digitalWrite(3,0); //yellow LEDs
digitalWrite(6,0);
digitalWrite(9,0);
digitalWrite(12,0);
digitalWrite(8,1);
digitalWrite(5,1);
digitalWrite(2,1);
digitalWrite(13,1);
//again delay
delay(5000);
digitalWrite(8,0);
digitalWrite(5,0);
digitalWrite(2,0);
digitalWrite(13,0);//YELLOW LEDS ON
digitalWrite(3,1); //yellow LEDs
digitalWrite(6,1);
digitalWrite(9,1);
digitalWrite(12,1);
delay(5000);
digitalWrite(3,0); //yellow LEDs // new sequence
digitalWrite(6,0);
digitalWrite(9,0);
digitalWrite(12,0);
digitalWrite(3,1);
digitalWrite(6,1);
digitalWrite(9,1);
digitalWrite(12,1); //now we have to give some delay
delay(1000);
//now all the yellow lights should be ON and all the previous LED should be off so
digitalWrite(4,0);
digitalWrite(10,0);
digitalWrite(11,0);
digitalWrite(7,0);
digitalWrite(3,1); //yellow LEDs
digitalWrite(6,1);
digitalWrite(9,1);
digitalWrite(12,1);
//again some delay for yellow LEds
delay(1000);
//now we have to turn off all the yellow leds and we have to turn on the up down green and right left red so
digitalWrite(3,0); //green leds
digitalWrite(6,0);
digitalWrite(9,0);
digitalWrite(12,0);
digitalWrite(3,1);
digitalWrite(6,1);
digitalWrite(9,1);
digitalWrite(12,1);
//again delay
delay(1000);
}