Traffic Light LED Display Module Onboard Red Yellow Green 5mm LED COM52, R28

Fr1,000

This is a mini-traffic light display module, high brightness, very suitable for the production of traffic light system model

In stock

SKU: DISP13887 Category:

Description

This is a mini-traffic light display module, high brightness, very suitable for the production of traffic light system model. It is featured with its small size, simple wiring, targeted, and custom installation. It can be connected PWM to control the brightness of the LED.

Features:

  1. Small size.
  2. Simple wiring.
  3. Targeted.
  4. Custom installation.

Interfacing LED Traffic Light Module with Arduino

Before you are getting started, prepare all the item needed:

  •  Arduino UNO
  • LED traffic light module
  • Jumper wires
  • Breadboard

Step 2: Connection Setup

Follow the connection as shown above.

Step 3: Sample Code

#define RED_SET_TIME 5000
#define YELLOW_SET_TIME 2000
#define GREEN_SET_TIME 5000
#define LIGHT_1_RED 2
#define LIGHT_1_YELLOW 3
#define LIGHT_1_GREEN 4
#define GREEN_LIGHT 0
#define YELLOW_LIGHT 1
#define RED_LIGHT 2
unsigned long gulStart_Timer = 0;
unsigned short gusSet_Time[3] = {GREEN_SET_TIME, YELLOW_SET_TIME, RED_SET_TIME};
short gsWhich_Light_Index = GREEN_LIGHT;
void setup()
{
  Serial.begin(9600);
  pinMode(LIGHT_1_RED, OUTPUT);
  pinMode(LIGHT_1_YELLOW, OUTPUT);
  pinMode(LIGHT_1_GREEN, OUTPUT);
  digitalWrite(LIGHT_1_GREEN, HIGH);
  digitalWrite(LIGHT_1_YELLOW, LOW);
  digitalWrite(LIGHT_1_RED, LOW);
  gulStart_Timer = millis();
}
// the loop function runs over and over again forever
void loop()
{
  if((millis()-gulStart_Timer) >= gusSet_Time[gsWhich_Light_Index])
  {
    gsWhich_Light_Index++;
    if(gsWhich_Light_Index > RED_LIGHT)
    {
      gsWhich_Light_Index = GREEN_LIGHT;
    }
    gulStart_Timer = millis();
    if(gsWhich_Light_Index == GREEN_LIGHT)
    {
      digitalWrite(LIGHT_1_GREEN, HIGH);
      digitalWrite(LIGHT_1_YELLOW, LOW);
      digitalWrite(LIGHT_1_RED, LOW);
    }
    else if(gsWhich_Light_Index == YELLOW_LIGHT)
    {
      digitalWrite(LIGHT_1_GREEN, LOW);
      digitalWrite(LIGHT_1_YELLOW, HIGH);
      digitalWrite(LIGHT_1_RED, LOW);
    }
    else if(gsWhich_Light_Index == RED_LIGHT)
    {
      digitalWrite(LIGHT_1_GREEN, LOW);
      digitalWrite(LIGHT_1_YELLOW, LOW);
      digitalWrite(LIGHT_1_RED, HIGH);
    }
  }
}

Reviews

There are no reviews yet.

Be the first to review “Traffic Light LED Display Module Onboard Red Yellow Green 5mm LED COM52, R28”