กลับไปหน้ารวมไฟล์
simple-traffic-lights-c012a3.md

I wanted to make a project for people just starting out, to be able to introduce them to the Wide World of Arduino. I learnt this the first time that I started working with Arduino, and I find it one of the easiest projects.


🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)

The Simple Traffic Lights project is the undisputed chapter two of every Arduino course. Once you have blinked a single LED, you must learn to sequence multiple outputs in a specific, timed order, simulating a real-world infrastructure scenario.

Building the Sequence (Linear Logic)

This project relies on the simplest, most linear coding structure possible inside the loop():

  1. Green Phase: digitalWrite(greenPin, HIGH); (Red and Yellow are LOW).
  2. The Hold: delay(5000); (Cars drive for 5 seconds).
  3. Yellow Phase: digitalWrite(greenPin, LOW); digitalWrite(yellowPin, HIGH);
  4. The Transition Hold: delay(2000); (Cars slow down for 2 seconds).
  5. Red Phase: digitalWrite(yellowPin, LOW); digitalWrite(redPin, HIGH);
  6. The Stop Hold: delay(5000);.

Because this is inside the loop(), as soon as the Red phase finishes, the code loops back to the top, automatically switching back to Green.

Breadboard Wiring Best Practices

This is where beginners learn electrical safety.

  • You cannot plug all three LEDs directly into the Arduino. If you do, you will pull too much current and burn out the ATMega chip.
  • Every single LED requires its own 220-ohm current-limiting resistor placed in series on the breadboard.
  • You learn how to use the "Rails" (the long blue and red lines on the edge of the breadboard) to tie all three LED grounds together, requiring only one wire to return to the Arduino's GND pin.

Component List

  • Arduino Uno/Nano.
  • Three 5mm LEDs (Red, Yellow/Amber, Green).
  • Three Resistors (220-ohm to 330-ohm).
  • Breadboard and jumper wires.

ข้อมูล Frontmatter ดั้งเดิม

title: "Simple Traffic Lights"
description: "A simple project for those who are just starting out."
author: "danields13"
category: ""
tags:
  - "simple"
views: 5287
likes: 1
price: 699
difficulty: "Easy"
components:
  - "1x Breadboard (generic)"
  - "3x Resistor 220 ohm"
  - "3x LED (generic)"
  - "1x Arduino UNO"
  - "1x Jumper wires (generic)"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "b356c7a16a15ad156da7da0d0a77f83d2adb28a8836def4a3d7cb531a9bfef4d"
encryptedPayload: "U2FsdGVkX1+5LoA2ZdWN+tc5kGZRhYv3OQHx9GvPtPXIav3YKWKdstaqcmp6d2NhmIU3uYUuAQUkP/1G2MEUmyd1HdVc2+eZFlnWgbvvFiQ="
seoDescription: "Build a Simple Traffic Lights project with Arduino. A perfect introductory guide for beginners to learn coding and electronics."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/simple-traffic-lights-c012a3_cover.jpg"
lang: "en"