traffic intersection
Author |
Message |
Veladen
|
Posted: Wed Jun 06, 2007 6:36 pm Post subject: traffic intersection |
|
|
Hi, can someone please help me with making a traffic intersection.
I have :
loop
parallelput (1) %Green
delay (5000)
parallelput (2) %Yellow
delay (3000)
parallelput (4) %Red
delay (8000)
end loop
the parallelports wires are attached to a breadboard with LED's that light up like a stoplight.
how can i make it so that they turn off and will go in order, instead of them all coming on at the same time, green, yellow and red all come on at the same time and green turns off after 5 seconds, yellow 3 seconds, red 8 seconds... how do i get them to work in order.
loop
parallelput (1) %Green
delay (5000)
parallelput (0)
parallelput (2) %Yellow
delay (3000)
parallelput (0)
parallelput (4) %Red
delay (8000)
parallelput (0)
end loop
this doesn't work either ^^ |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DIIST
|
Posted: Wed Jun 06, 2007 8:57 pm Post subject: Re: traffic intersection |
|
|
Okay it seems you are an engineering student who is doing the traffic light intersection project. A few notes of advice other than use code tags .
Assume D0,D1,D2 connects to the green, yellow and red LED respectively
send the byte 0000 0001 to parallel port
You should receive an input in D0, and only D0 (so green light should go on)
Like wise:
sends the byte 0000 0010 to the parrallel port.
You should only receive a input from D1. (so yellow light should go on)
There seems to be nothing wrong with your first piece of code. Just something probably wrong with your bread board setup. You could try posting a picture of the bread board and we might be able to help you there. If you want all of them to turn on at once, you just need to send an input to all three ports DO,D1,D2. So you need to send the byte 0000 0111 which is just parallelput(7). This all will work assuming you are not using some multiduplexer config |
|
|
|
|
|
Veladen
|
Posted: Wed Jun 06, 2007 9:02 pm Post subject: Re: traffic intersection |
|
|
No, what's happening is that they're all turning on at the same time, I can't figure out how to delay them from turning on. The breadboard is fine, all it is is a parallel port wire, LED, and a ground. |
|
|
|
|
|
DIIST
|
Posted: Wed Jun 06, 2007 9:08 pm Post subject: Re: traffic intersection |
|
|
What are you exactly saying, you are using delay (1000). delay(milliseconds), 1000miliseconds = 1 second. Thats how you would delay them from turning onn. Just in case, could you probably post a diagram of you current bread board setup. Something is not making sense. |
|
|
|
|
|
Veladen
|
Posted: Thu Jun 07, 2007 6:45 am Post subject: Re: traffic intersection |
|
|
it has to work like a real traffic light... so green has to come on first, for 5 seconds while red and yellow are off. Then green turns off for 8 seconds while yellow is on for 3, and red is off. Then green stays off and yellow turns off and red turns on for 8 seconds. Then it repeats. How can I do that? There is only way to set up the breadboard, i'll try to draw it.
. . PP4. . . . .R. + . D. . -. .. . GND
. . PP3 . . . R . . +. D. ..- .. .. GND
. . PP2 . . . .R. . .+ . D. .- . . GND
PP = Parrallelport wire
D= divider
R= resistor
+ = positive side of LED
- = negative side of LED
GND = Ground
so basically there's 3 lines of wires, each being the same. The bottom one is green LED, middle yellow and top red. |
|
|
|
|
|
rollerdude
|
Posted: Fri Jun 08, 2007 12:04 pm Post subject: Re: traffic intersection |
|
|
you said that they go off instead of go on in order?
what if you tried puting
parallalput(6**2) %110
parallelput(5**2) %101
parallelput(3**2) %011
why you "**2" is unknown to me, but when i tried making a 7 segment display, and using turing help, thas how it says to do it, in which case, i'd try ur numbers 1,2 and 4 first, and then mine, to see if it works... |
|
|
|
|
|
DIIST
|
Posted: Fri Jun 08, 2007 12:24 pm Post subject: Re: traffic intersection |
|
|
rollerdude @ June 8th 2007 wrote:
what if you tried puting
parallalput(6**2) %110
parallelput(5**2) %101
parallelput(3**2) %011
Even Better :
|
|
|
|
|
|
Veladen
|
Posted: Fri Jun 08, 2007 2:30 pm Post subject: Re: traffic intersection |
|
|
ok thanks ill try that |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|