0% found this document useful (0 votes)
7 views3 pages

Practical 2

The document outlines a simulation exercise for students to create a traffic light system using a virtual Arduino board on platforms like Tinkercad or Wokwi. It includes step-by-step instructions for setting up the simulation environment, designing the system with LEDs, programming the Arduino, and running the simulation. The exercise aims to teach students about real-time operations and sequential control in embedded systems, making it suitable for beginners.

Uploaded by

clinton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Practical 2

The document outlines a simulation exercise for students to create a traffic light system using a virtual Arduino board on platforms like Tinkercad or Wokwi. It includes step-by-step instructions for setting up the simulation environment, designing the system with LEDs, programming the Arduino, and running the simulation. The exercise aims to teach students about real-time operations and sequential control in embedded systems, making it suitable for beginners.

Uploaded by

clinton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Simulating a Traffic Light System

Objective:
Students will simulate an embedded system for a traffic light using a laptop and a virtual Arduino
board. This will help them understand how embedded systems handle real-time operations and
sequential control.

Requirements:
 Laptop with internet access
 Free account on Tinkercad or Wokwi
 Arduino programming basics

Step-by-Step Instructions:
1. Setup the Simulation Environment (10 minutes):
 Go to Tinkercad or Wokwi.
 Log in and create a new Arduino project.

2. Design the Traffic Light System (10 minutes):


 Drag and drop the following components into the simulator:
o Arduino Uno
o 3 LEDs (red, yellow, and green)
o 3 resistors (220 ohms each)
 Connect the components as follows:
o Connect the red LED to pin 13 via a resistor and GND.
o Connect the yellow LED to pin 12 via a resistor and GND.
o Connect the green LED to pin 11 via a resistor and GND.

3. Program the Arduino (15 minutes):


 Open the code editor in the simulator and paste the following code:
cpp
CopyEdit
int redLed = 13; // Red LED connected to pin 13
int yellowLed = 12; // Yellow LED connected to pin 12
int greenLed = 11; // Green LED connected to pin 11

void setup() {
pinMode(redLed, OUTPUT); // Set red LED pin as output
pinMode(yellowLed, OUTPUT); // Set yellow LED pin as output
pinMode(greenLed, OUTPUT); // Set green LED pin as output
}

void loop() {
// Green light for 5 seconds
digitalWrite(greenLed, HIGH);
delay(5000); // 5 seconds
digitalWrite(greenLed, LOW);

// Yellow light for 2 seconds


digitalWrite(yellowLed, HIGH);
delay(2000); // 2 seconds
digitalWrite(yellowLed, LOW);

// Red light for 5 seconds


digitalWrite(redLed, HIGH);
delay(5000); // 5 seconds
digitalWrite(redLed, LOW);
}
 Save and upload the code to the virtual Arduino.
4. Run and Observe the Simulation (15 minutes):
 Start the simulation in the simulator platform.
 Watch the LEDs light up in sequence: green (5 seconds), yellow (2 seconds), and red (5
seconds).
 Modify the delay values in the code to change the light durations if desired.

5. Discussion and Reflection (10 minutes):


 Discuss how this simple traffic light simulation demonstrates the following:
o Real-time operation: LEDs turn on/off at precise intervals.
o Sequential control: Events happen in a predefined order.
o Application-Specific Design: Mimics a real-world traffic light system.
 Brainstorm enhancements, such as:
o Adding a pedestrian crossing signal.
o Using buttons to simulate manual overrides.
o Implementing timers on an LCD display.

Expected Outcome:
Students will understand the basics of embedded system design by simulating a traffic light
system. This exercise emphasizes real-time control and sequential logic, foundational concepts
for embedded systems.
This exercise is suitable for beginners and requires only a laptop for execution.

You might also like