I'm making a traffic light intersection with a crosswalk down the road, the two for loops are for the advanced green. The code for the button is for the crosswalk and i want the two sets to run independently so that the traffic lights are not at all affected by the button code.
Combination2.ino (1.67 KB)
Please go read the forum guidelines in the sticky post. They will show you how to get help on this forum. Most forum members read on phones & tablets and cannot open .ino files, so please use code tags instead.
After you have done that, perhaps you could say what your problem is, what do you need help with?
digitalWrite(green1, HIGH);
delay(8000);
digitalWrite(green1, LOW);
digitalWrite(yellow1, HIGH);
delay(5000);
digitalWrite(yellow1, LOW);
digitalWrite(red1, HIGH);
delay(1000);
digitalWrite(red2, LOW);
start with learning to program the sequence of light changes without using delay()
Ah, the classic "doing several things at once" question?
You will need to learn about using millis() instead of delay() and using "state machines". There are sticky posts about those things at the top of the Programming section of the forum.