Project 9 Traffic Light

1.Description

Today, we will meet a friend. He has three expressions and often instruct us to obey the traffic rules. Do you know who he is? Let’s explore together!

Task analysis

Sensor

Red, Yellow and Green Module

Role

Sasha/convertible 3

Background

Urban

Result

People will stop at red light and walk when it turns green

2.Traffic Light Module Introduction

There are 6 ports on the traffic light module, including 3 GND ports, which are connected. The module comes with 3 LED lights in red, yellow and green, among which G controls the green light, Y controls the yellow light, and R controls the red light .

We can control the 3 LEDs on and off on the module , and simulate the roadside traffic lights flashing.

Specifications

  • Operating voltage: DC 3.3V-5V

  • Control port:Digital port

  • Dimension: 42mm * 47mm * 12mm

  • Weight: 5.7g

  • Environmental protection attributes: ROHS

3.Components Needed

Control Board * 1

USB Cable*1

Connection Wires

Traffic Light Module*1

4.Connection Diagram

5.Test Program

1.Open“KidsBlock”software to create a new project.

2.Delete the beetle role.

3.Select “Urban”:click the background library iconin the lower right corner to select Urban.

4.Select Sasha/convertible 3, as shown below:

5.Flow Chart

6.Build the program

①Select “Sasha”and build the program, as shown below:

②Select “convertible 3”and build the program, as shown below:

6.Test Result

Connect the wirings and the device then select the port, then click.If the green light on the traffic module is on, Sasha will walk across the road, and the green light will be off after 5s. Then the yellow light will flash for two times, and the red light will be on, convertible 3 will start to drive and turn off after 5s, as shown in the picture below:

7.Program Explanation

Instruction

Function

Initialize the red, yellow and green lights on the traffic light module

Turn on the green light and Sasha will move to the coordinate(X:-147,Y:-207)

Turn off the green light and the yellow light will flash for 2 times

After a delay of 5s, Sasha returns to its original position

7s is the total time spent by the Sasha
Turn off the green and yellow light
Turn on the red light , convertible 3 will move to the coordinate(X:296,Y:-123)
Turn off the red light, convertible 3returns to its original position