Traffic light with Micro:bit (2024)

A traffic light, also known as a traffic signal, stop light, or traffic control signal, is a signaling device that is used to control the flow of vehicular and pedestrian traffic. The main function of a traffic light is to control the priority of traffic at intersections and other locations where multiple roads meet.

A typical traffic light consists of three main lights: red, yellow, and green. The red light indicates that vehicles and pedestrians should stop and not proceed through the intersection. The yellow light, also known as the caution or amber light, indicates that the red light is about to change and that vehicles and pedestrians should prepare to stop or proceed with caution. The green light indicates that vehicles and pedestrians can proceed through the intersection.

Some traffic lights may also include additional lights, such as a walk signal for pedestrians, a left-turn signal for vehicles, or a flashing yellow light for special conditions.

Traffic lights are typically controlled by a central traffic control system, which uses sensors and cameras to detect the presence of vehicles and pedestrians at the intersection and adjust the timing of the lights accordingly. Some traffic lights may also be controlled by a traffic control officer, who manually adjusts the timing of the lights based on traffic conditions.

The traffic light systems can be used to control the traffic flow in the peak hours, reduce the traffic congestion, improve the safety, and also to reduce the pollution. The traffic lights are also used in the pedestrian crosswalks for the safety of the pedestrians.

Aim of this project:

A traffic light controlled by a Micro:bit is a project where the Micro:bit board is used to control a set of LEDs that mimic the behavior of a real traffic light. The Micro:bit board can be programmed to control the LEDs in a way that simulates the different states of a traffic light, such as red, yellow, and green.

One way to accomplish this is to use the Micro:bit’s built-in LEDs as the traffic lights. The Micro:bit can be programmed to light up the LEDs in a sequence that mimics the behavior of a real traffic light, such as lighting up the red LED for a certain amount of time, then the yellow LED for a certain amount of time, and finally the green LED for a certain amount of time. The timing of the lights can be adjusted using the Micro:bit‘s built-in timer functions.

Alternatively, external LEDs can be connected to the Micro:bit‘s I/O pins. The Micro:bit can be programmed to control the external LEDs by sending voltage signals to the appropriate I/O pins. In this case, the Micro:bit can be used to switch the LEDs between on and off states.

It is also possible to use the Micro:bit to control the traffic light using a servo motor, which is a type of motor that can rotate to a specific position, hold that position, and rotate at different speeds. The Micro:bit can be programmed to send control signals to the servo motor, which will rotate the traffic light to the appropriate position for each state (red, yellow and green).

In this project we will create a traffic light where the Red led lights up for 3 seconds, then goes out and the Green led lights up for 3 seconds and then goes out so that the orange led turns on. lights up for 1 second. Then the program starts over and starts over.

Components required

Micro:bit board

Traffic light with Micro:bit (1)

Micro:bit is a small, low-cost microcontroller board that was developed by the Micro:bit Educational Foundation for use in computer education. It is designed to be easy to use and accessible to a wide range of users, including children and beginners. The Micro:bit board measures about 4cm by 5cm and features a 25-pin edge connector, a 5×5 LED matrix, two programmable buttons, an accelerometer, a compass, a Bluetooth Low Energy (BLE) module, and a USB connector.

The Micro:bit is programmed using a variety of programming languages such as Python, JavaScript, and Microsoft Block Editor. It can be used to control a wide range of devices and projects, including robots, drones, lights, and more. The board can be powered by a USB cable or a 3V coin cell battery and can be programmed using a computer or mobile device.

The Micro:bit is widely used in education, providing a hands-on learning experience for students of all ages to learn computer programming, logic, and problem-solving. It’s also used by hobbyist and makers to create fun and interactive projects.

Microbit GPIO board

Traffic light with Micro:bit (2)

A Micro:bit GPIO (General Purpose Input/Output) Expansion Board is an accessory that can be used to extend the capabilities of a Micro:bit by providing additional input/output (I/O) pins. These pins can be used to connect sensors and actuators, such as LEDs, buttons, motors, and other electronic components.

The expansion board typically connects to the Micro:bit using a standard edge connector and provides a set of male headers that can be used to connect external components.

3 resistors of 220Ω

Traffic light with Micro:bit (3)

Resistance is a measure of a material’s opposition to the flow of electric current. It is measured in ohms (Ω) and is represented by the symbol “R”. The more resistance a material has, the less current will flow through it when a given voltage is applied. Conversely, the less resistance a material has, the more current will flow through it when a given voltage is applied.

Red LED- Yellow LED – Green LED

Traffic light with Micro:bit (4)

An LED (Light Emitting Diode) is a semiconductor device that emits light when an electric current is passed through it. LEDs are widely used in a variety of applications because they are energy-efficient, have a long lifespan, and are available in a wide range of colors.

LEDs can be found in many electronic devices such as televisions, smartphones, computers, and traffic lights. They are also used in automotive lighting, general illumination, and as indicator lights.

Connecting wires

Traffic light with Micro:bit (5)

Connecting wires refers to the process of physically connecting wires or cables to a device or circuit in order to establish an electrical connection. This can be done by using various connectors such as plugs, sockets, or terminal blocks. The wires are typically color-coded to indicate their function, such as red for power, black for ground, and yellow for signals.

Test plate

Traffic light with Micro:bit (6)

A test plate is a type of circuit board that is used to test electronic components. It typically consists of a flat board made of a non-conductive material, such as plastic or fiberglass, with a number of holes or pads that are used to connect electronic components. The test plate allows you to connect electronic components and test them easily.

wires

Mounting

To perform the assembly, you can connect the green LED to pin P0, the yellow LED to pin P1 and the red LED to pin P2 of the micro: bit card. There are many mounting methods and here are some examples:

Mounting (1)

Mounting (2)

Makecode program

Here is the traffic light makecode program:

Download program

Traffic light with Micro:bit (2024)

References

Top Articles
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 5722

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.