You are on page 1of 4

De La Salle University – Dasmariñas

College of Engineering, Architecture and Technology

Electronics Engineering Department

ECET421La
Fundamentals of Robotics

Laboratory Activity No. 4


Sensor (Potentiometer) Serial Communications

Villanueva, Kyle Janssen M.


ECE41
Group no. 3

DOP: March 20, 2019


DOS: March 27, 2019

ENGR. JACKLYN KATE GARDUQUE


Instructor
I. Objectives
This experiment will enable the student
1. To convert analog signal to digital value for the Arduino to process.
2. To control the angular displacement of the robotic arm using the potentiometer.
3. To create a computer program user interface to display data coming from Arduino

II. Introduction:

In this activity we will going to control the joints of the robotic arm using a potentiometer as a sensor. We
will configure the potentiometer into a voltage divider circuit and feed the middle pin to the Arduino to have a
variable value as we rotate the knob of the potentiometer.

We will make use the analog to digital conversion of the Arduino microcontroller in order to process the
data. The data will be converted to angular displacement that will be feed to the servomotor connected in the
robotic arm.

MS Visual Studio provides graphical user interface (GUI) to display the information received by the
Arduino from the potentiometer. The display is just made of textbox that time to time will received the data from
the arduino

III. Procedure

1. Connect the computer and Arduino microcontroller using USB serial cable
2. Connect the black cable to ground, red cable to 5V and yellow to pin 9 of the microcontroller respectively.

IV. Data

#include <Servo.h>
Servo servo;
Servo servo2;
Servo servo3;

void setup() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
servo.attach(8);
servo2.attach(12);
servo3.attach(13);
}
void loop() {
servo.write(map(analogRead(A0), 0 , 1023, 0, 180));
servo2.write(map(analogRead(A1), 0 , 1023, 0, 180));
servo3.write(map(analogRead(A2), 0 , 1023, 0, 180));
}
V. Conclusion
By using Arduino we were able to control the Servo motor and able to adjust its angle as the
potentiometer turns into a certain degree, the experiment was successful since each time the
potentiometer is turned the servo motor follows. As seen on our data, we used the statement “
servo.write(map(analogRead(A0), 0 , 1023, 0, 180)); “ this enable the Arduino to interact with the
servomotor and the potentiometer thus making it possible to control the angle of turn of the servo
motor using the Arduino.

You might also like