Read Analog Value Of Joystick; Introduction; Parameters; Principle - Keyestudio ESP32 Manual

Smart robot arm kit
Hide thumbs Also See for ESP32:
Table of Contents

Advertisement

keyestudio WiKi
// in steps of 1 degree
servo.write(pos);
delay(20);
}
for
(pos
=
180; pos
servo.write(pos);
delay(20);
}
}
9.1.7.2 Result

9.2 9.2 Read Analog Value of Joystick

9.2.1 9.2.1 Introduction

The joystick module adopts a PS2 handle rocker. When controlling, we connect the X and Y ports to the analog port of
the MCU, port B to the digital port, VCC to the power output(3.3-5V), and GND to the GND. We can read the power
level of the digital port and two analog values to know the state of the joystick module.

9.2.2 9.2.2 Parameters

Operating voltage: 3.3V ~ 5V
Three axes: X, Y, Z
Dimensions: 44.2 x 28 x 32.8mm

9.2.3 9.2.3 Principle

Axis X and Y are actually two potentiometers.
As shown below, the analog value of the X(Y) axis ranges from 0 ~ 4095 (the analog value of ESP32 is 0 ~ 4095).
124
// waits 20ms for the servo to reach the position
>=
0; pos
-=
1) {
// sweep from 180 degrees to 0 degrees
(continued from previous page)
Chapter 9. 9. Robot Arm Projects

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32 and is the answer not in the manual?

Table of Contents