I am trying to program 6 LED's as traffic lights and I am trying to get the to work like an intersection i can get the one set to work but i am having trouble getting the other to work any ideas?
this is my code for the one set of lights
int red = 5;
int yellow = 4;
int green = 3;
int red1 = 11;
int yellow1 = 10;
int green1 = 9;
void setup(){
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
pinMode(red1, OUTPUT);
pinMode(yellow1, OUTPUT);
pinMode(green1, OUTPUT);
}
void loop(){
changeLights();
delay(15000);
}
void changeLights(){
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
delay(4000);
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
delay(8000);
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(4000);
any ideas?
There must be something wrong with your wiring of the LEDs, the resistors, or the switches, or there must be something wrong with your code.
What did I win?
Mikey2018:
this is my code for the one set of lights
You need also to post the program you tried which you are having trouble with and tell us what it actually does and what you want it to do that is different.
And to make it easy for people to help you please use the code button </> so your code looks like this
and is easy to copy to a text editor. See How to use the Forum
...R
Hello there!
Is this your complete code?
Try to pass arguments to the changelights function: first time the 3 pins of the first traffic light, second time the pins of the other traffic light. If you don't know how to pass arguments to a function, look for some tutorial on the internet.