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

Arduino UNO-Based Analog Joystick Interface

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Analog Joystick Interface

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with an Analog Joystick (Wokwi Compatible). The joystick provides two-dimensional input by outputting analog signals corresponding to the X (horizontal) and Y (vertical) axes. The Arduino UNO reads these analog signals and outputs the joystick's position through its serial interface. This setup can be used for various control applications, such as robotics or game controllers.

Component List

Arduino UNO

Analog Joystick (Wokwi Compatible)

Wiring Details

Arduino UNO

Analog Joystick (Wokwi Compatible)

Documented Code

// Code for Arduino UNO to read joystick values and print them to the serial monitor

const int xPin = A0; // Joystick horizontal axis
const int yPin = A1; // Joystick vertical axis
float xValue, yValue;

void setup() {
  pinMode(xPin, INPUT); // Set the joystick horizontal axis as input
  pinMode(yPin, INPUT); // Set the joystick vertical axis as input
  Serial.begin(9600);   // Start serial communication at 9600 baud
}

void loop() {
  xValue = analogRead(xPin); // Read the horizontal axis value
  yValue = analogRead(yPin); // Read the vertical axis value

  // Print the values to the serial monitor
  Serial.print("Value of x-axis: ");
  Serial.println(xValue);
  Serial.print("Value of y-axis: ");
  Serial.println(yValue);

  delay(100); // Wait for 100 milliseconds before the next read
}

Filename: sketch.ino

This code initializes the Arduino UNO to read the analog values from the joystick's vertical and horizontal axes. It then prints these values to the serial monitor every 100 milliseconds. The xPin and yPin are defined as constants corresponding to the Arduino's analog input pins A0 and A1, respectively. The setup() function initializes the serial communication and configures the joystick pins as inputs. The loop() function continuously reads the analog values from the joystick and outputs them to the serial monitor.