Tags: Led, Traffic, Lights, Light emitting diode, Module

LED Traffic Lights Module

  • 9.00 AED
    • Ex Tax:9.00 AED
    • Product Code: 3 LED's Traffic Lights
    • Availability: In Stock
    This is a mini-traffic light display module, high brightness, very suitable for making a traffic light project. It has a small size, simple wiring pins, and installation. It can be connected to PWM to control the brightness of the 3 LEDs. Features: Small size. Simple wiring. Targeted. Custom ..

    This is a mini-traffic light display module, high brightness, very suitable for making a traffic light project. It has a small size, simple wiring pins, and installation. It can be connected to PWM to control the brightness of the 3 LEDs.

    Features:

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

    Before you get started, prepare all the item needed:

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

    How to wire and connect the LED Traffic Lights Module With Arduino:

    Connection Setup

    #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();
    }
    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);
     }
     }
    }

    Uploading

    After open the code in Arduino IDE, go to the [Tools] --> [Boards Manager] --> select [Arduino/Genuino UNO] as we using Arduino UNO in this tutorial.

    Then connecting the Arduino UNO to PC, after that select the correct port (go to [Tools] --> [Port] --> Select correct port for Arduino UNO).

    Next, compile and upload the code into your Arduino UNO.

    There are no reviews for this product.

    Write a review

    Please login or register to review