Professional Documents
Culture Documents
ECET421La
Fundamentals of Robotics
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.