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

Arduino UNO Controlled Servo with Joystick and LED Indicator

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Servo with Joystick and LED Indicator

Circuit Documentation

Summary

The circuit consists of an Arduino UNO microcontroller, a micro servo 9G, a two-pin red LED, and a KY-023 Dual Axis Joystick Module. The Arduino UNO is used as the central processing unit, controlling the servo based on the input from the joystick and driving the LED. The servo is controlled via PWM signal, and the joystick provides analog input to the Arduino. The LED serves as an indicator and is connected to one of the digital pins on the Arduino. All components share a common ground, and the servo and joystick are powered by the 5V output from the Arduino.

Component List

Arduino UNO

Micro servo 9G

LED: Two Pin (red)

KY-023 Dual Axis Joystick Module

Wiring Details

Arduino UNO

Micro servo 9G

LED: Two Pin (red)

KY-023 Dual Axis Joystick Module

Documented Code

#include <Servo.h>
Servo servo;

int js = A0; // Joystick input connected to A0

void setup() {
  Serial.begin(9600);
  servo.attach(8); // Servo control attached to pin 8
  servo.write(90); // Center the servo
}

void loop()
{
  int gerak = analogRead(js); // Read the joystick value
  Serial.println(gerak); // Print the joystick value to the serial monitor
  if(gerak > 800)
  {
    servo.write(0); // Move servo to 0 degrees
  }
  else if(gerak < 400)
  {
    servo.write(180); // Move servo to 180 degrees
  }
  else
  {
    servo.write(90); // Center the servo
  }
}

The code is written for the Arduino UNO and is responsible for reading the analog input from the joystick connected to pin A0. Depending on the input value, the servo motor is controlled to move to specific positions (0, 90, or 180 degrees). The servo is attached to pin 8, which is not explicitly mentioned in the wiring details but can be inferred from the code. The serial communication is initialized for debugging purposes, allowing the user to monitor the joystick's analog values.