0% found this document useful (0 votes)
16 views7 pages

How To Read The Data of The Potentiometer

Uploaded by

greg772900
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)
16 views7 pages

How To Read The Data of The Potentiometer

Uploaded by

greg772900
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/ 7

How to Read the Data of the Potentiometer

In this lesson, we will learn how to read the data of the potentiometer and
convert the data into an angle.

1. Components used in this course

Components Quantity Picture

Adeept Arm Drive Board 1

Micro USB Cable 1

2. Introduction of Potentiometer

The potentiometer is a resistance element with three terminals and the


resistance value can be adjusted according to a certain change law, which is
equivalent to a variable resistor. Because its role in the circuit is to obtain a
certain relationship with the input voltage (external voltage) to output Voltage,
so called potentiometer. Potentiometers can be divided into rotary
potentiometers, push-pull potentiometers, straight slide potentiometers, etc.
according to the adjustment method. Our course experiment uses a rotary
potentiometer. It’s three pins are showed as below:
The rotary potentiometer is an adjustable resistance element. It is composed
of a resistor and a rotating system. When a voltage is applied between the two
fixed contacts of the resistive body, the position of the contact on the resistive
body is changed by the rotating system, and a voltage that has a certain
relationship with the position of the moving contact can be achieved between the
1
moving contact and the fixed contact. Potentiometer can be used to adjust the
voltage and current.
Our course uses a rotary potentiometer. Its structure is as shown in the
figure below. By rotating the knob, the position of pin 2 is changed, thereby
changing the resistance value from pin 2 to both ends. In the experiment.
Connect pin 1 and pin 3 to the GND and 5V of the development board respectively.
And then read the voltage divided by the pin 2 of the potentiometer through the
analog input pin A0, the range is between 0V and 5V. The analog input function of
Arduino has 10-bit precision, that is, it can convert the voltage signal of 0 to 5V
into an integer form of 0 to 1024.

3. Wiring diagrams (Circuit diagram)

Figure as below:

2
4. Reading the value of the potentiometer and
converting it into an angle

4.1. Compile and run the code program of this course

1. Open the Arduino IDE, as shown below:

2. In the Tools toolbar, find Board and select Arduino Uno, as shown below:

Or:

3
3. Click Open in the File drop-down menu:

4. Find the Package of Documentation (Reference: Chapter: "_4 build Arduino


development environment", step 2 under subsection (3) under subsection 5)
that we provide to the user. Open the directory in sequence: “Code” -> “1.
Potentiometer” -> “potentiometer”. Then select the code file "potentiometer.ino"
and click the "Open" button.

5. After opening, click to upload the code program to the Adeept Arm Drive

Board. If there is no error warning in the console below, it means that the Upload
is successful.

4
6. After successfully running the program, click to observe the value of the

potentiometer by opening the serial monitor, as shown in the figure below:

Then open the serial monitor, you need to modify the displayed bit rate and
the bit rate set in the code to 115200, so that the display will not appear garbled.
You can observe the data changes corresponding to each button by rotating the
buttons of A0, A1, A2, A3, and A6. When the buttons of A0, A1, A2, and A3 are
rotated, the data change range is from 0 to 180. The data becomes smaller when
rotating clockwise, and the data becomes larger when rotating counterclockwise.
When the A6 button is rotated, the data change range is 35~90. When it is
rotated clockwise, the data becomes smaller, and when it is rotated
counterclockwise, the data becomes larger.

5
4.2. Learning the code of this lesson

Initialize potentiometers A0, A1, A2, A3, A6.

Initialize serial port baud rate.

Convert the value of 0~1023 to 0~180 proportionally, and then print out the
converted data to the serial monitor.

6
7

You might also like