For the 'Embedded Systems' strand of my 'Systems Technology' module at Nottingham Trent University, I had to develop a traffic light controller (TLC).
To develop this system I used an Elegoo Uno R3 along with components (listed here). My solution to this problem goes beyond the core requirements for the coursework piece, as it implemented a class, enum, and uses a 7 segment display and 8 bit shift register.
I have not yet finished the wiring diagram for this project. You can try and build the circuit from the below image / using the code if you wish.
- Launch TLC.ino using Arduino IDE or other IDE that supports Arduino
- Select the correct Arduino board type (for this project I used Arduino Uno)
- Select the correct COM port
- Compile & upload the program to the Arduino board
- Should work!
The TLC needed to be able to function in 3 distinct modes, outlined below:
- Regular Mode - Three LEDs should alternate (only 1 LED on at a time) to simulate a traffic light, the three colours being red, yellow and green. The sequence is:
- Red for 2 seconds
- Yellow for 1 second
- Green for 2 seconds
- Yellow for 1 second
- Pedestrian Mode - This mode utilises an ultrasonic range finder in order to determine the distance of a 'pedestrian'. The sequence outlines in regular mode happens until a pedestrian is detected to be within 10cm of the sensor, one this happens, a buzzer sounds and the yellow LED flashes 10 times at 0.1s intervals, and then returns to the sequence.
- Night Mode - This mode uses a light dependent resistor (LDR) in order to work out how much ambient light is present. The LEDs alternate in the sequence outlined in regular mode until the ambient light falls below the set threshold, once this happens, the red LED will stay on unless something is detected to be within 10cm of th ultrasonic range finder, if this is the case the green LED will light until either the ambient light is great enough for night mode to deactivate or the object is no longer within 10cm.
The following list covers the core components used for solution (all included in this kit):
- Elegoo Uno R3
- Red, Green and Yellow LED
- Piezo Buzzer
- Ultrasonic Sensor
- Light Dependant Resistor
- Buttons
- 8 Bit Shift Register (IC74HC595)
- 7 Segment Display
- Resistors (220Ω and 1kΩ)
- Diode Rectifier (1N4007)
- Wires
- Breadboard