Joy Stick Interfacing with Arduino and LEDs in proteus

Joy Stick Interfacing with Arduino and LEDs in proteus

In this article we will learn how to interface arduino with Joy stick and LEDs in proteus.
In the last post we will learn how to interface arduino with Automatically IN and Out sensor in proteus. You can visit our website,
I hope you appreciate my work, let’s discuss about today’s project.

Joy Stick Interfacing with Arduino and LEDs in proteus
Joy Stick Interfacing with Arduino and LEDs in proteus

Components which we use in this project are listed below:

  1. Arduino UNO
  2. Resistor variable (1k)
  3. Resistor 10k (4)
  4. LEDs (4)
  5. Jumper wires

Diagram of this project is below:

Construction of Joy Stick Interfacing with Arduino and LEDs in proteus:

  • Connect the Collector pins of Resistor variables with the +ve
  • Connect the Ammeter pins of Resistor variables with the GND
  • Connect the signal pin of resistor variable of X-Axis with the pin A1 of Arduino
  • Connect the signal pin of resistor variable of Y-Axis with the pin A0 of Arduino
  • Connect the pin 12 of Arduino with the one side of R1
  • Connect the other side of R1 with the +ve side of LED 1
  • Connect the –ve side of LED 1 with the GND
  • Connect the pin 8 of Arduino with the one side of R2
  • Connect the other side of R2 with the +ve side of LED 2
  • Connect the –ve pin of LED 2 with the GND
  • Connect the pin 11 of Arduino with the one side of R3
  • Connect the other side of R3 with the +ve side of LED 3
  • Connect the –ve pin of LED 3 with the GND
  • Connect the pin 9 of Arduino with the one side of R4
  • Connect the other side of R4 with the +ve side of LED 4
  • Connect the –ve pin of LED 4 with the GND

Working of Joy Stick Interfacing with Arduino and LEDs in proteus:

A joystick is a input device that allows users to control the movement of a cursor or other elements on a screen, such as a computer monitor or a gaming console. It consists of two potentiometers (one for the X-axis and one for the Y-axis) and a button. By moving the joystick in different directions and pressing the button, you can send various signals to a microcontroller like Arduino.

Applications of Joy Stick Interfacing with Arduino and LEDs in proteus:

  1. Gaming Controller
  2. Remote Control
  3. Pan-and-Tilt Camera
  4. Light Painting
  5. Home Automation

Advantages of Joy Stick Interfacing with Arduino and LEDs in proteus:

  1. Precise Control
  2. User Interaction
  3. Versatility
  4. Customization
  5. Educational Tool

Program code of this project is below:

/// www.projectiot123.com

 

#define Xaxis_pin A0 // Arduino pin connected to the VRx Pinzs

#define Yaxis_pin A1 // Arduino pin connected to the VRy Pin

#define SW_pin A2    // Arduino pin connected to the SW Pinz

#define X_LED_pin 8  // Arduino pin connected to the X-axis LED

#define X1_LED_pin 9 // Arduino pin connected to the X1-axis LED

#define LED_pin 10   // Arduino pin connected to the common LED

#define Y_LED_pin 11 // Arduino pin connected to the Y-axis LED

#define Y1_LED_pin 12// Arduino pin connected to the Y1-axis LED

 

int xThreshold = 32;

int x1Threshold = 700;// Set the X-axis threshold value here (adjust as needed)

int yThreshold = 30;

int y1Threshold = 700;// Set the Y-axis threshold value here (adjust as needed)

 

void setup() {

pinMode(SW_pin, INPUT_PULLUP); // Use INPUT_PULLUP for the switch input

pinMode(X_LED_pin, OUTPUT);   // Initialize the X-axis LED pin as an output

pinMode(X1_LED_pin, OUTPUT);  // Initialize the X1-axis LED pin as an output

pinMode(LED_pin, OUTPUT);     // Initialize the common LED pin as an output

pinMode(Y_LED_pin, OUTPUT);   // Initialize the Y-axis LED pin as an output

pinMode(Y1_LED_pin, OUTPUT);  // Initialize the Y1-axis LED pin as an output

Serial.begin(9600);

}

 

void loop() {

int xValue = analogRead(Xaxis_pin);

int yValue = analogRead(Yaxis_pin);

int switchState = digitalRead(SW_pin);

 

Serial.print(“X-axis: “);

Serial.print(xValue);

Serial.print(” : “);

Serial.print(“Y-axis: “);

Serial.print(yValue);

Serial.print(” : “);

Serial.print(“Switch: “);

Serial.println(switchState);

 

// Check X-axis value against thresholds

if (xValue > xThreshold) {

digitalWrite(X_LED_pin, LOW);

delay(200);

} else {

digitalWrite(X_LED_pin, HIGH);

delay (200);

}

 

if (xValue < x1Threshold) {

digitalWrite(X1_LED_pin, LOW);

delay (200);

} else {

digitalWrite(X1_LED_pin, HIGH);

delay (200);

}

 

// Check Y-axis value against thresholds

if (yValue > yThreshold) {

digitalWrite(Y_LED_pin, LOW);

delay (200);

} else {

digitalWrite(Y_LED_pin, HIGH);

delay (200);

}

 

if (yValue < y1Threshold) {

digitalWrite(Y1_LED_pin, LOW);

delay (200);

} else {

digitalWrite(Y1_LED_pin, HIGH);

delay (200);

}

 

// Check switch state

if (switchState == LOW) {

digitalWrite(LED_pin, LOW);

delay (200); // Turn on the common LED when the switch is pressed

} else {

digitalWrite(LED_pin, HIGH);delay (200);

}

 

delay(200); // Add a small delay for stability

}