ChedderCheeser
Senior Member
Hi all! I just finished my first actual project with Picaxe! It is a traffic light. I added some other code to make it more.. interesting. I also used code that wasnt NEEDED in case.. idk.. I just did. To make it more interesting. The problem is.. the timing is a bit weird... Heres the timing:
Green : 15 seconds
Yellow : 3.5 seconds
Red : 8 seconds
But.. that doesnt seem much like a REAL traffic light... Heres my code:
Also, I DONT want to remove the un-needed code. So.. dont mention that lol. So, what timings do you recomend? THX!!
Green : 15 seconds
Yellow : 3.5 seconds
Red : 8 seconds
But.. that doesnt seem much like a REAL traffic light... Heres my code:
Code:
Init:
setfreq m4 ;Not needed, but used anyway
output 4 ;Not really needed, but used
output 2 ;Not really needed, but used
output 1 ;Not really needed, but used
gosub flash ;Just to test the led's. NOT NEEDED AT ALL
pause 750 ;Not needed, but used
goto Main ;Not really needed, but used
Main:
do
high 4 ;Green On
pause 15000 ;Wait 15 seconds
low 4 ;Green Off
pause 100 ;Wait 0.1 seconds
high 2 ;Yellow off
pause 3500 ;Wait 3.5 seconds
low 2 ;Yellow off
pause 100 ;Wait 0.1 seconds
high 1 ;Red on
pause 8000 ;Wait 8 seconds
low 1 ;Red off
pause 100 ;Wait 0.1 seconds
loop
End
flash:
high 4
high 2
high 1
pause 250
low 4
low 2
low 1
pause 250
high 4
high 2
high 1
pause 250
low 4
low 2
low 1
return