0% found this document useful (0 votes)
7 views

Procedure 2

procedure 2

Uploaded by

samehselem77766
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Procedure 2

procedure 2

Uploaded by

samehselem77766
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

LAB 10

Procedure 2: Joystick Board


• Description:
We want to design an embedded system using Arduino Uno board that will control a joystick
and servo moor. Figure 1 shows the 2-axis joystick board.

Figure 1: 2-axis joystick board.

The two-axis joystick board is a board that you can use in various robotic projects, controls
and control systems. It gives analog output on two axes, X and Y axis. In addition, there is a
button in the middle of the joystick. There is a power LED on the board.

The joystick is a module that contains two potentiometers that allow movement in two axes
and acts as a button in its vertical movement. We often see joysticks in game consoles and
remote-control vehicles. It is possible to make many different projects with joystick modules
compatible with Arduino. It is possible to see many different applications such as motor
control, LED control, robotic controls.

Arduino Joystick shield button has a characteristic that works inversely to other buttons. So,
it's a pullup button. We read 1 when we do not press the button, and 0 when we press it. Figure
2 presents the pinout structure of the Joystick module. There is a separate data pin for all
vertical, horizontal and button movements. In order for the module to work, 5V and GND must
be supplied.
Y axis X axis Button

Figure 2: Joystick's pins

• Components:

Components Quantity

Arduino Uno Board 1

Breadboard 1

2-axis Joystick board 1

Servo Motor 1

USB Cable 1

Jumper Cables (M-M) 6


• Hardware Circuit:
You have to interface the following circuit as shown in Figure 3. Here, we want to read an
analog input from the joystick board. To do that, you have to connect the joystick board's
vertical pin (VER) to Arduino's analog input pin A0. Moreover, connect the servo motor's
pulse pin to Arduino's digital pin 3. Then, map the read value from [0,1023] to [0,180]. Finally,
send he mapped value to pulse pin of the servo motor.

Figure 3: The hardware circuit’s design.


• Sketch:

#include <Servo.h>
const int JOYSTICK_Y_PIN = A0;
const int SERVO_PIN = 3;
Servo servo;
void setup() {
servo.attach(SERVO_PIN);
// Setting the servo to its initial position at 0 degrees
servo.write(0);
// Wait for the servo to reach its position
delay(100);
Serial.begin(9600);
}

void loop() {
// Read the joystick input on y axes
int y = analogRead(JOYSTICK_Y_PIN);
// Converting the joystick values to a range that can be used to control the servo
int angle = map(y, 0, 1023, 0, 180);
// Set the servo to the calculated angle
servo.write(angle);
Serial.print("Angle: ");
Serial.println(angle);
delay(10);
}

• Proteus Simulation:
Note: To simulate the circuit in Proteus, add a potentiometer instead of 2-axis joystick board
and connect its output pin to the Arduino’s A0 pin.
Figure 4: Simulation output 1
Figure 5: Simulation output 2
Figure 6: Simulation output 3
Figure 7: Simulation output 4

You might also like