MeArm Robot Arm Kit

Bought myself a MeArm robot arm kit to practice coding and robotics

MeArm – Your Robot – ADAM Red

Hooked up to a Arduino Mega 2560

img_20161225_124915564_hdr

Assembled MeArm

img_20161225_124923367_hdr

Connect to the Arduino Mega 2560. Using potentio-meter’s to control the angle of the servos.

serial

Serial monitor to check the positioning of the servos.

Simple code to get setup with the MeArm

#include <Servo.h>

Servo myservo1; // create servo object to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;

int potpin1 = 0; // analog pin used to connect the potentiometer
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;

int val1; // variables to read the value from the analog pin
int val2;
int val3;
int val4;

void setup() {
myservo1.attach(5); // attaches the servo on pin 9 to the servo object
myservo2.attach(6);
myservo3.attach(9);
myservo4.attach(10);

Serial.begin(9600);
}

void loop() {
val1 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val1 = map(val1, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)

myservo1.write(val1); // sets the servo position according to the scaled value

val2 = analogRead(potpin2);
val2 = map(val2, 0, 1023, 0, 180);

myservo2.write(val2);

val3 = analogRead(potpin3);
val3 = map(val3, 0, 1023, 0, 180);

myservo3.write(val3);

val4 = analogRead(potpin4);
val4 = map(val4, 0, 1023, 0, 180);

myservo4.write(val4); // Printing Servo Values
Serial.print(“Servo1: “);
Serial.print(val1);
Serial.print(” Servo2: “);
Serial.print(val2);
Serial.print(” Servo3: “);
Serial.print(val3);
Serial.print(” Servo4: “);
Serial.println(val4);
delay(15); // waits for the servo to get there
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s