Skip to content

Project 2.11.3: Manual Traffic Speed Dial

Description This project uses a potentiometer to control the cycling speed of a Traffic Light Module, allowing the user to speed up or slow down the light sequence in real-time.
Use case This project can be used in automation systems, interactive installations, and embedded control applications.

Components (Things You will need)

Arduino Uno Arduino USB Cable Breadboard Jumper Wires Potentiometer Traffic Light Module

Building the circuit

Things Needed:

  • Arduino Uno = 1
  • Arduino USB cable = 1
  • Potentiometer = 1
  • Traffic light module = 1
  • Breadboard = 1
  • Jumper wires

Mounting the component on the breadboard

Step 1: Place the Potentiometer and the Traffic Light Module on the breadboard.

Components on breadboard

NB: Make sure all components are securely placed on the breadboard with correct orientation.

WIRING THE CIRCUIT

Step 2: Connect one outer pin of the Potentiometer to GND pin on the Arduino Uno using male-to-male jumper wires.

Components on breadboard

Step 3: Connect the other outer pin of the Potentiometer to 5V pin on the Arduino Uno using male-to-male jumper wires.

Components on breadboard

Step 4: Connect the middle pin of the Potentiometer to Analog pin A0 on the Arduino Uno using male-to-male jumper wires.

Components on breadboard

Step 5: Connect the Green LED (G) of the Traffic Light Module pin to Digital Pin 4 on the Arduino Uno using male-to-male jumper wires.

Components on breadboard

Step 6: Connect the Yellow LED (Y) of the Traffic Light Module pin to Digital Pin 5 on the Arduino Uno using male-to-male jumper wires.

Components on breadboard

Step 7: Connect the Red LED (R) of the Traffic Light Module pin to Digital Pin 6 on the Arduino Uno using male-to-male jumper wires.

Components on breadboard

Step 8: Connect the GND of the Traffic Light Module pin to GND on the Arduino Uno using male-to-male jumper wires.

Components on breadboard

Make sure to connect the Arduino USB cable to the Arduino board.

PROGRAMMING

Step 1: Open your Arduino IDE. See how to set up here: Getting Started.

Step 2: Type the following code in your Arduino IDE: const int potPin = A0;, const int greenLED = 4;, const int yellowLED = 5;, const int redLED = 6;, int potValue;, int delayTime; as shown in the image below.

Components on breadboard

Step 3: Type the following code in your Arduino IDE inside the void setup() pinMode(greenLED, OUTPUT);, pinMode(yellowLED, OUTPUT);, pinMode(redLED, OUTPUT);, Serial.begin(9600); as shown in the image below.

Components on breadboard

Step 4: Type the following code in your Arduino IDE inside the void loop() potValue = analogRead(potPin);, delayTime = map(potValue, 0, 1023, 200, 2000);, Serial.print("Delay Time: ");, Serial.print(delayTime);, Serial.println(" ms"); as shown in the image below.

Components on breadboard

Step 5: Type the following code in your Arduino IDE inside the void loop() digitalWrite(greenLED, HIGH);, digitalWrite(yellowLED, LOW);, digitalWrite(redLED, LOW);, delay(delayTime); as shown in the image below.

Components on breadboard

Step 6: Type the following code in your Arduino IDE inside the void loop() digitalWrite(greenLED, LOW);, digitalWrite(yellowLED, HIGH);, digitalWrite(redLED, LOW);, delay(delayTime); as shown in the image below.

Components on breadboard

Step 7: Type the following code in your Arduino IDE inside the void loop() digitalWrite(greenLED, LOW);, digitalWrite(yellowLED, LOW);, digitalWrite(redLED, HIGH);, delay(delayTime); as shown in the image below.

Components on breadboard

Uploading the code

Step 1: Save your code. See the Getting Started section

Step 2: Select the Arduino board and port. See the Getting Started section

Step 3: Upload your code.

CONCLUSION

This project helps learners understand how to combine multiple components with Arduino to create more complex interactive systems and automation solutions.