In this experiment, we need to build a traffic light system and interface to the PIC microcontroller. Use three onboard MX20 LEDS as a group of lights. For the second set of light construct the tape on the breadboard and connect to the 25-way connector on the MX20 board. We need a switch to choose between a safe sequence and an unsafe sequence. Write a program for the PIC microcontroller to control the following traffic light system. There are six lights to operate. The red, amber, and green lights in the north-south direction will be designated as R1, A1, and G1. Similarly, the east-west direction lights will be called R2, A2, and G2. When the digital output signal is in Logic-1 state, they will turn on their respective indicator lights, otherwise the indicator lights will be off. There are two types of road intersections: unsafe intersections that use a simple sequence, and safe intersections that require a longer (delayed green) sequence. A digital input signal named SAFE will be used to switch traffic lights between SAFE and UNSAFE sequences. (Logic 1 selects the SAFE sequence, logic 0 selects the unsafe sequence). When the traffic light switches to the SAFE sequence, a beep is generated to indicate that pedestrians can cross the intersection (ie red, red).
正在翻译中..