Project tutorial
The Traffic Light

The Traffic Light © CC BY-NC-ND

Three LEDs: green, yellow and red that create a traffic light.

  • 5,336 views
  • 5 comments
  • 17 respects

Components and supplies

Apps and online services

About this project

Hello! My name is Matei. I'm eleven years old and this is my second project. In this project, I made a traffic light with three LEDs: green, yellow and red. This project demonstrates how to define an Arduino pin.

Code

The traffic lightC/C++
#define LED_GREEN A0
#define LED_YELLOW A1
#define LED_RED A2
void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Go!");
  digitalWrite(A0, HIGH);
  delay (10000);
  digitalWrite(A0, LOW);
  Serial.println ("Stop!");
  digitalWrite(A2, HIGH);
  delay (10000);
  digitalWrite(A2, LOW);
  Serial.println("Reduce speed!");
  digitalWrite(A1, HIGH);
  delay (3000);
  digitalWrite(A1, LOW);
}

Schematics

traffic light
If you don't understand the wiring, tell me in the comments section and I will help you.
traffic_light_L8zSdTwnEC.fzz

Comments

Similar projects you might like

Arduino Traffic Light Simulator

Project tutorial by Zachary Haslam

  • 8,025 views
  • 1 comment
  • 20 respects

Traffic Light Information System

Project tutorial by Pieter Luyten and Joppe Smeets

  • 16,237 views
  • 18 comments
  • 36 respects

Light Sequence Creator

Project tutorial by Reid Paulhus

  • 9,074 views
  • 2 comments
  • 20 respects

Traffic Monitor- Monitors traffic on the Go

Project tutorial by Patel Darshil

  • 3,732 views
  • 0 comments
  • 8 respects

LED Blink Pattern

Project tutorial by Matt Arnold

  • 30,330 views
  • 14 comments
  • 84 respects

Smart Traffic Light

Project showcase by Fady Tarek

  • 8,061 views
  • 8 comments
  • 19 respects
Add projectSign up / Login