QB095 Traffic Light Module

1.Product Introduction

../../_images/Traffic_Light_Module-1.png

The traffic light module integrates three different color LEDs: red, yellow, and green. It has four pins, one of which is a common pin, and the other three pins control the operation of three different color LEDs. The common GND is connected to the GND port of the development board, and the R, Y, and G pins are connected to different I/O ports of the development board. When each R, Y, and G pin inputs a high level, the corresponding color LED will light up.

Application reference: Traffic lights, indicators, etc.

2.Parameter Specification

Parameter

Value//Description

Operating voltage

3.3V~5V

Operating temperature

-40°C~+70°C

Output signal

Digital signal

Size

4.8cm*2.4cm

../../_images/Traffic_Light_Module-2.png

3.Wiring Diagram

Hint

Expansion board is attached to esp32 controller board.

../../_images/Traffic_Light_Module-3.png

Traffic Light Module

UNO

G

0

Y

2

R

14

GND

GND

4.Sample Code

 1#define R 14  //Define the pin for the red light of the traffic light
 2#define Y 2   //Define the pin for the yellow light of the traffic light
 3#define G 0   //Define the pin for the green light of the traffic light
 4
 5void setup() {
 6  pinMode(R, OUTPUT);  //Set the red light pin to output mode
 7  pinMode(Y, OUTPUT);  //Set the yellow light pin to output mode
 8  pinMode(G, OUTPUT);  //Set the green light pin to output mode
 9}
10
11void loop() {
12  Traffic_Light(0, 0, 1);  //Green light on
13  delay(2000);             //Delay 2 seconds
14  Traffic_Light(0, 1, 0);  //Yellow light on
15  delay(1000);             //Delay 1 seconds
16  Traffic_Light(1, 0, 0);  //Red light on
17  delay(3000);             //Delay 3 seconds
18}
19//Define traffic light color control function
20
21void Traffic_Light(int r, int y, int g) {
22  digitalWrite(R, r);
23  digitalWrite(Y, y);
24  digitalWrite(G, g);
25}

5.Test Result

When you have successfully connected the circuits according to the wiring diagram and successfully uploaded the correct program, your traffic light will be green for 2 seconds, yellow for 1 second, and red for 3 seconds.

../../_images/Traffic_Light_Module-4.png

6.Related Resources

7.Get One Now

B2B Business: info@acebott.com

Individual buyer: shop on aliexpress