Help with pushbuttons
ctodd901
Posts: 5
i have to design and simulate a intersection with two stop lights and a push button to simulate a pedestrian crosswalk. and im having trouble getting the pushbutton to do what i want it to. I have to be able to push the pushbutton at any time during the two stop light sequences and then have the crosswalk go green after the street lights turn red. so my question is there a way to store the status of a push button and store that in a variable until the end of the stoplight sequence and then use that variable in some sort of if statement?
Comments
thanks for the quick response but im still having trouble getting the push button state to hold it value. Every time the light switches from green to yellow to red the push button resets itself to 0?
Are you using the BUTTON command to debounce your switches?
1. Design and implement a basic stamp based circuit that would simulate the working of two sets of traffic lights at an intersection.
2. Add a pushbutton to allow pedestrians to cross one street. When the button is pushed, all traffic should stop (not immediately). The pedestrian light will turn green and will stay so for 30 seconds, unless the button is pressed again before the pedestrian light turns red. The last 10 second, the green light will be flashing to indicate that time is almost up to crossing the street. The push button can be only pushed twice at a time for a maximum of one minute. After that, it will return to red and normal operation will resume. Use the bi-color LED for your pedestrian light.
Sounds like a school project?
It would not be fair to write the code for you, but if you have some code that you have already written, and are stumped in a certain area, we would be glad to help.
HIGH 2
HIGH 13
PAUSE 2000
'1st traffic light sequence
LOW 13
HIGH 15
PAUSE 2500
LOW 15
HIGH 14
PAUSE 2000
LOW 14
HIGH 13
PAUSE 5000
' second traffic light sequence
LOW 2
HIGH 0
PAUSE 2500
LOW 0
HIGH 1
PAUSE 2000
LOW 1
HIGH 2
PAUSE 2500
LOOP
Are you familiar with Flowcharts?
http://en.wikipedia.org/wiki/Flowchart
They are really helpful to get an idea together, and helps out a lot with the programming down the road.
.