Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Traffic Light with Joystick Interface

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Traffic Light with Joystick Interface

Circuit Documentation

Summary of the Circuit

This circuit consists of an Arduino UNO microcontroller, a joystick module, and a traffic light module. The Arduino UNO serves as the central processing unit, interfacing with the joystick module to receive user input and controlling the traffic light module to display different lights based on the joystick's position or button press. The joystick module provides analog input from its two axes (VRX and VRY) and a digital input from its switch (SW). The traffic light module has three LEDs representing the green, yellow, and red lights, which are controlled by the digital outputs from the Arduino UNO.

Component List

Arduino UNO

Joystick Module

Traffic Light

Wiring Details

Arduino UNO

Joystick Module

Traffic Light

Documented Code

void setup() {
  // Initialize the traffic light pins as outputs
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);

  // Initialize the joystick button pin as an input
  pinMode(D7, INPUT);
}

void loop() {
  // Read the joystick button state
  int buttonState = digitalRead(D7);

  // Control the traffic light based on the joystick button
  if (buttonState == HIGH) {
    // Button pressed, turn on the Red light
    digitalWrite(D1, HIGH);
    digitalWrite(D2, LOW);
    digitalWrite(D3, LOW);
  } else {
    // Button not pressed, cycle through Green and Yellow lights
    digitalWrite(D1, LOW);
    digitalWrite(D3, HIGH); // Turn on the Green light
    delay(2000);            // Keep Green light on for 2 seconds
    digitalWrite(D3, LOW);
    digitalWrite(D2, HIGH); // Turn on the Yellow light
    delay(1000);            // Keep Yellow light on for 1 second
    digitalWrite(D2, LOW);
  }
}

Note: The provided code is a basic template and does not include the functionality to read the analog joystick positions (VRX and VRY). Additional code would be required to implement features based on the joystick's X and Y-axis movements.