Introduction: Arduino - Robotic Arm Control With a Potentiometer
In this tutorial, we will learn how to use robotic arm control with potentiometer.
We will control 4 axis robot arm with 4 pcs potentiometer.
We will use external battery / power when doing this.
Step 1: Hardware Required
- 4 Axis Robot Arm Kit
- Arduino Board
- 10k Potentiometer 4 pcs
- Battery and Battery Buckle
- Wires and Breadboard
Recommended site to buy the required hardware:
https://www.banggood.com/?p=CS120478587752016125
Step 2: Robot Arm Servo Kit Review
Feature:
Name: DIY robotic arm NO.99
Size: 140 x 80 x 130mm (L x W x H)
Servo: P0090, 180 ° rotation
Usage:
DIY assembling toys, teaching experiments (can be any combination of various forms of machinery, it can be widely installed remote control, a variety of robot car, etc.)
4 DOF Robot Arm Servo Kit -- https://goo.gl/6UZJL6
Step 3: Connections
- The external battery VCC / GND connect to the breadboard.
- The Arduino GND connect to the breadboard's GND input
The servo connections we use in this project are as follows;
Orange Input - Signal Input
Red Input - Power Input (VCC)
Brown Input - Ground Input(GND)
- The Servo1 VCC and GND connect to the breadboard's VCC / GND inputs
- The Servo1 Signal connect to the Arduino Digital PWM 3
- The Servo2 VCC and GND connect to the breadboard's VCC / GND inputs
- The Servo2 Signal connect to the Arduino Digital PWM 5
- The Servo3 VCC and GND connect to the breadboard's VCC / GND inputs
- The Servo3 Signal connect to the Arduino Digital PWM 6
- The Servo4 VCC and GND connect to the breadboard's VCC / GND inputs
- The Servo4 Signal connect to the Arduino Digital PWM 9
The potentiometer connections we use in this project are as follows;
Two outer pins are power (VCC) and ground (GND)
Middle pin is signal pin
- The Potentiometer's one outer pin connect to the breadboard or the Arduino board VCC input
- The Potentiometer's other outer pin connect to the breadboard or the Arduino board GND input
- The Potentiometer's middle pin connect to the Arduino Analog 1-2-3-4 input
Step 4: Code
1) Get the Code (Only Copy and Paste)
2) Add the Servo library
3) Define Servos
4) Define Potentiometers
5) Variable to read the values from the analog pin (potentiometers)
6) Attaches our servos on pins PWM 3-5-6-9 to the servos
7) Reads the value of potentiometers (value between 0 and 1023)
8) Scale it to use it with the servo (value between 0 and 180)
9) Set the servo position according to the scaled value
10) Upload the code
6 Comments
3 years ago
Hello,
Thanks so much for this wonderful article!
I can't seem to get the code, though—could you help?
Reply 3 years ago
Hi I managed to save it before it was removed:
//add servo library
#include <Servo.h>
//define our servos
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
//define our potentiometers
int pot1 = A1;
int pot2 = A2;
int pot3 = A3;
int pot4 = A4;
//variable to read the values from the analog pin (potentiometers)
int valPot1;
int valPot2;
int valPot3;
int valPot4;
void setup()
{
//attaches our servos on pins PWM 3-5-6-9 to the servos
servo1.attach(3);
servo1.write(0); //define servo1 start position
servo2.attach(5);
servo2.write(90); //define servo2 start position
servo3.attach(6);
servo3.write(90); //define servo3 start position
servo4.attach(9);
servo4.write(70); //define servo4 start position
}
void loop()
{
//reads the value of potentiometers (value between 0 and 1023)
valPot1 = analogRead(pot1);
valPot1 = map (valPot1, 0, 1023, 0, 180); //scale it to use it with the servo (value between 0 and 180)
servo1.write(valPot1); //set the servo position according to the scaled value
valPot2 = analogRead(pot2);
valPot2 = map (valPot2, 0, 1023, 0, 180);
servo2.write(valPot2);
valPot3 = analogRead(pot3);
valPot3 = map (valPot3, 0, 1023, 0, 180);
servo3.write(valPot3);
valPot4 = analogRead(pot4);
valPot4 = map (valPot4, 0, 1023, 70, 150);
servo4.write(valPot4);
}
Question 5 years ago
Wont it burn out? im using a sainsmart palatalizing robotic arm with 4 axis and upping the voltage to 9 volts. we are making a robot that can we can play chess with
Question 5 years ago on Introduction
What is estmated cost on it?\
6 years ago
Cool! Thanks man!
U wrote very short code for this! It is realy awesome!
Thanks!
6 years ago
Awesomely Cool!!!. Could you attach a fritzing of all the connections?? I would love it if you do so :)