Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Laboratory #2_ Arduino Traffic Light

The document outlines a laboratory exercise for creating a traffic light simulation using Arduino and Tinkercad. It details the objective, setup, and code required to simulate the traffic light sequence with specific timing for each light. Additionally, it includes requirements for circuit assembly and provides a video link for further reference.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Laboratory #2_ Arduino Traffic Light

The document outlines a laboratory exercise for creating a traffic light simulation using Arduino and Tinkercad. It details the objective, setup, and code required to simulate the traffic light sequence with specific timing for each light. Additionally, it includes requirements for circuit assembly and provides a video link for further reference.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Laboratory #2: Arduino Traffic Light

Name: Darrell Kim B. Garcia


Program: BSIT
Instructor: Prof. Mark Philip Felipe

Objective: To create and simulate a simple Arduino application using Tinkercad simulation.
To be able to apply the principle of Digital Write, I/O Activation, and Delay.
To be able to understand the concept of real life application of programming.

Short Lecture:

The reason that Arduino has the two functions setup and loop is to separate the things that only
need to be done once, when the Arduino starts running its sketch, from the things that have to
keep happening continuously. The function setup will just be run once when the sketch starts.
Let’s add some code to it that will blink the LED built onto the board. Add the lines to your
sketch so that it appears as follows and then upload them to your board:

void setup() { // initialize the digital pin as an output.

pinMode(13, OUTPUT);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

} // the loop routine runs over and over again forever: void loop() { }

General Instructions:

1. Assemble the Arduino Circuit


a. 1 Arduino Board
b. 3 1k resistor
c. 3 LED (Red, Yellow, Green)
2. Using the Text Code create a program that would create a light sequence similar to a
traffic light (use the principle of blinking light sample code)
a. Stop - 10 sec, Yellow 5 sec, Go - 15 sec.
b. Sequence - Red Green Yellow Red Green

Laboratory Output Requirements.

Code:
// Traffic Light Simulation
// Name: Darrell Kim Garcia
// Date: 3-12-25
// Code that simulates a basic traffic light system using Arduino.
// Light sequence: R - G - Y - R - G

const int redLED = 13; // To Stop


const int yellowLED = 12; // To proceed with Caution
const int greenLED = 11; // To Go

void setup() {
// Initialize LED pins as OUTPUT
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
}

void loop() {
digitalWrite(redLED, HIGH); // To stop
delay(10000); // 10sec
digitalWrite(redLED, LOW);

digitalWrite(greenLED, HIGH); // To Go
delay(15000); // 15sec
digitalWrite(greenLED, LOW);

digitalWrite(yellowLED, HIGH); // To proceed with caution


delay(5000); // 5sec
digitalWrite(yellowLED, LOW);

digitalWrite(redLED, HIGH); // To Stop


delay(10000); // 10sec
digitalWrite(redLED, LOW);

digitalWrite(greenLED, HIGH); // To Go
delay(15000); //15sec
digitalWrite(greenLED, LOW);
}

Screenshot:
Code, Circuit (Including Time and Date of the Desktop)

Video Link:
https://drive.google.com/file/d/1Z2j4sEU7kKvHYeHYSUIip8x6rIoXCHvn/view?usp=sharing

You might also like