Traffic Lights Arduino Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

TRAFFIC LIGHT CODE

CONALEP Veracruz l

Alumns:

PAVON RAFAEL NEFTALI

GARCÍA GARCÍA DAVID ALI

VASQUEZ ESTRADA YAEL DE JESUS

Carrer:

OMIN OPERATION OF MICROS AND INTERFACES

Teacher:

ING. Cesar Armando Jiménez Álvarez


Summary:

In the handy Arduino traffic light code, the operation of a traffic light is simulated

using LED lights and programming. Three LEDs are usually used to represent the

colors of the traffic light: red, yellow and green. The code in the Arduino controls

the sequence of lights to simulate the changing of colors in the traffic light, using

time intervals for each state (green, yellow, red) and possibly a button or sensor to

simulate the detection of vehicles or pedestrians.


Introduction:

 How to make a very simple traffic light using Arduino. This project will

involve using a very simple code and circuit that is ideal for beginners. This

simple little project uses an Arduino and some LEDs to replicate a traffic

light. It uses code as an internal timer and continues to run until you cut off

the Arduino’s power supply.

MATERIALS

1. Arduino development board

2. Cables to connect the components to each other and to the Arduino board.

3. Resistances

4. Colorful LEDs: red, yellow, green

6. Breadboard

7. Power supply for Arduino board: You can power the Arduino board through the

USB cable connected to your computer or through an external power supply.

These materials will allow you to build the circuit and program the code necessary

to simulate a traffic light with Arduino.


Images of the process
Code in Arduino that simulates the traffic light

Int greenLed = 4;

Int yellowLed = 3;

Int redLed = 2;

Void setup() {

pinMode(greenLed, OUTPUT);

pinMode(yellowLed, OUTPUT);

pinMode(redLed, OUTPUT);

Void loop() {

For (int I = 0; I < 3; i++) {

digitalWrite(greenLed, HIGH); // Enciende el LED verde

delay(10000); // Espera 10 segundos

digitalWrite(greenLed, LOW); // Apaga el LED verde

digitalWrite(yellowLed, HIGH); // Enciende el LED amarillo

delay(3000); // Espera 3 segundos


digitalWrite(yellowLed, LOW); // Apaga el LED amarillo

digitalWrite(redLed, HIGH); // Enciende el LED rojo

delay(5000); // Espera 5 segundos

digitalWrite(redLed, LOW); // Apaga el LED rojo

delay(1000); // Espera un segundo antes de iniciar el siguiente ciclo

In this example, a for loop is used to repeat the traffic light sequence three times.

The ignition timing for each traffic light color is adjusted to reflect the specific

sequence used in Mexico.


Procedure

To make a traffic light with Arduino, you will need to follow these steps

1. Gather the Materials: Arduino board, three LEDs (red, yellow and green)

2. Component Connection: Connect each LED to the breadboard with its

respective resistor. Next, connect the anode of each LED to a digital pin on the

Arduino board (for example, pin 2 for the red LED, pin 3 for the yellow, and pin 4

for the green).

3.Code Upload: Connect the Arduino board to your computer, open the Arduino

development environment, copy the code and upload the program to the board.

4. Test: Once the code is loaded onto the Arduino board, watch the sequence run

on the LEDs to make sure they are working correctly.

Always remember to handle electronic components with care and pay attention to

the correct polarity of LEDs and resistors.


Conclusions

In the “LED flashing” project the team learned to apply fundamental concepts of

electronics and programming. By connecting an LED to the Arduino board, writing

the code to make it blink, and uploading the code to the board, we acquire basic

but important skills in the field of electrical engineering and computer science. This

project lays the foundation for more advanced projects and provides a practical

understanding of the operation of electronic systems controlled by microcontrollers.

Links

Traffic Light using Arduino - A Beginner Project. (s. f.). projecthub.arduino.cc.

https://projecthub.arduino.cc/agarwalkrishna3009/traffic-light-using-arduino-a-beginner-

project-35f8c6

Hackster.io. (2022, 17 abril). Traffic Light using Arduino - A Beginner Project.

https://www.hackster.io/agarwalkrishna3009/traffic-light-using-arduino-a-beginner-project-

8b3b2b

You might also like