Traffic Light¶
Uses¶
3 LED Lights (Red, Amber, Green), buttons, pins
Description¶
In this challenge you will make a traffic light that turns green when no button press was detected. When a pedestrian presses a button, it will turn to amber for a few seconds, then it will turn red. It will wait for a certain amount of time for the pedestrian to walk across the street, then it will turn to a blinking amber then green again.
You will be utilizing the 3 pins (pin0, pin1 and pin2) for the 3 LED lights (green, amber and red, respectively), and GND pin.
Traffic lights, or technically traffic control signals, are signalling devices positioned at road intersections, pedestrian crossings, and other locations to control flows of traffic. Traffic lights alternate the right of way accorded to users by displaying lights of a standard colour (red, amber (yellow), and green) following a universal colour code.
Basic Game¶
- Send a high (1) signal to
pin0to tun on the green light. - If button a was pressed, it will wait for a seconds, then turn off green by sending a low (0) signal and send a high signal to
pin1(amber). - After 3 seconds, send a low signal to
pin1(amber light) and send a high signal topin2(red light). - Wait for 7 seconds before sending a low signal to
pin2, then make the amber light blink for 4 seconds by alternating writing high and low and inserting asleep()function. - Turn off the amber light and turn on the green light, and wait for a button press again.