// 6-Axis Robotic Arm designed and coded by Evan John David Steer
// 16th July 2022
#include <Servo.h>
Servo RightWheelServo;
Servo LeftWheelServo;
Servo BaseServo;
Servo NeckServo;
Servo HeadServo;
Servo ArmServo;
Servo WristServo;
Servo HookServo;
int RightDriveWheel = 12;
int LeftDriveWheel = 13;
int BasePotentiometer = 6; // analog pin used to connect the potentiometer
int NeckPotentionmeter = 5; // analog pin used to connect the potentiometer
int HeadPotentiometer = 4; // analog pin used to connect the potentiometer
int ArmPotentiometer = 3; // analog pin used to connect the potentiometer
int WristPotentiometer = 2; // analog pin used to connect the potentiometer
int HookPotentiometer = 1; // analog pin used to connect the potentiometer
int SlidePotentiometerValue = 66;
int Joystick1VERTICAL = 10;
int Joystick1HORZONTAL = 12;
int Joystick1VERT = 20;
int Joystick1HORZ = 30;
void setup()
{
pinMode(A10, INPUT);
pinMode(A12, INPUT);
RightWheelServo.attach(13);
LeftWheelServo.attach(12);
BaseServo.attach(7);
NeckServo.attach(6);
HeadServo.attach(5);
ArmServo.attach(4);
WristServo.attach(3);
HookServo.attach(2);
Serial.begin(300);
}
void loop()
{
SlidePotentiometerValue = analogRead(6); // reads the value of the potentiometer (value between 0 and 1023)
SlidePotentiometerValue = map(SlidePotentiometerValue, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
BaseServo.write(SlidePotentiometerValue); // sets the servo position according to the scaled value // waits for the servo to get there
//
SlidePotentiometerValue = analogRead(5); // reads the value of the potentiometer (value between 0 and 1023)
SlidePotentiometerValue = map(SlidePotentiometerValue, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
NeckServo.write(SlidePotentiometerValue); // sets the servo position according to the scaled value // waits for the servo to get there
//
SlidePotentiometerValue = analogRead(4); // reads the value of the potentiometer (value between 0 and 1023)
SlidePotentiometerValue = map(SlidePotentiometerValue, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
HeadServo.write(SlidePotentiometerValue); // sets the servo position according to the scaled value // waits for the servo to get there
//
SlidePotentiometerValue = analogRead(3); // reads the value of the potentiometer (value between 0 and 1023)
SlidePotentiometerValue = map(SlidePotentiometerValue, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
ArmServo.write(SlidePotentiometerValue); // sets the servo position according to the scaled value // waits for the servo to get there
//
SlidePotentiometerValue = analogRead(2); // reads the value of the potentiometer (value between 0 and 1023)
SlidePotentiometerValue = map(SlidePotentiometerValue, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
WristServo.write(SlidePotentiometerValue); // sets the servo position according to the scaled value // waits for the servo to get there
//
SlidePotentiometerValue = analogRead(1); // reads the value of the potentiometer (value between 0 and 1023)
SlidePotentiometerValue = map(SlidePotentiometerValue, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
HookServo.write(SlidePotentiometerValue); // sets the servo position according to the scaled value // waits for the servo to get there
//
Joystick1VERT = (analogRead(A10));
Joystick1HORZ = (analogRead(A12));
Joystick1VERT = map(Joystick1VERT, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
Joystick1HORZ = map(Joystick1HORZ, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
RightWheelServo.write(Joystick1VERT); // sets the servo position according to the scaled value // waits for the servo to get there
RightWheelServo.write(Joystick1HORZ); // sets the servo position according to the scaled value // waits for the servo to get there
LeftWheelServo.write(Joystick1VERT); // sets the servo position according to the scaled value // waits for the servo to get there
LeftWheelServo.write(Joystick1HORZ); // sets the servo position according to the scaled value // waits for the servo to get there
}