Arduino Stop Light Project: Difference between revisions

From ikev.in/w
No edit summary
No edit summary
Line 28: Line 28:


3. Upload the following code to the Arduino Uno:
3. Upload the following code to the Arduino Uno:
{{
 
int redPin = 6;
int redPin = 6;
int greenPin = 5;
int greenPin = 5;
Line 50: Line 50:
digitalWrite(greenPin, LOW);
digitalWrite(greenPin, LOW);
}
}
}}
 
Challenges
==Challenges==
One of the challenges of this project is to make sure that the LEDs light up in the correct order.
One of the challenges of this project is to make sure that the LEDs light up in the correct order.
Another challenge is to make sure that the LEDs stay lit for the correct amount of time.
Another challenge is to make sure that the LEDs stay lit for the correct amount of time.
Tips
 
==Tips==
If you are not sure how to connect the components, you can find many tutorials online.
If you are not sure how to connect the components, you can find many tutorials online.
It is always a good idea to test your code before you connect the components. This will help you to identify any errors in the code.
It is always a good idea to test your code before you connect the components. This will help you to identify any errors in the code.
Be careful when working with electricity. Always make sure that the power is off before you start working on the project.
Be careful when working with electricity. Always make sure that the power is off before you start working on the project.

Revision as of 02:33, 16 September 2023

This Arduino Stop Light Project project uses an Arduino Uno, three LEDs, and three resistors to create a working traffic light.

Materials

  • Arduino Uno
  • Three LEDs
  • Three 220 ohm resistors
  • Breadboard
  • Jumper wires

Instructions

1. Connect the LEDs to the Arduino Uno as follows:

GND -----> GND Red LED -----> D6 Green LED -----> D5 Yellow LED -----> D4


2. Connect the resistors to the LEDs as follows:

Red LED -----> 220 ohm resistor -----> GND Green LED -----> 220 ohm resistor -----> GND Yellow LED -----> 220 ohm resistor -----> GND


3. Upload the following code to the Arduino Uno:

int redPin = 6; int greenPin = 5; int yellowPin = 4;

void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(yellowPin, OUTPUT); }

void loop() { digitalWrite(redPin, HIGH); delay(2000); digitalWrite(redPin, LOW); digitalWrite(yellowPin, HIGH); delay(1000); digitalWrite(yellowPin, LOW); digitalWrite(greenPin, HIGH); delay(3000); digitalWrite(greenPin, LOW); }

Challenges

One of the challenges of this project is to make sure that the LEDs light up in the correct order. Another challenge is to make sure that the LEDs stay lit for the correct amount of time.

Tips

If you are not sure how to connect the components, you can find many tutorials online. It is always a good idea to test your code before you connect the components. This will help you to identify any errors in the code. Be careful when working with electricity. Always make sure that the power is off before you start working on the project.