I can't make a picture (my camera doesn't work) so I've made some drawings.
draw 1:
draw 2:
Important:
-When arm is setted as shown on draw 2, servos have to be in their middle positions (90 degree)
-distance between servo 1 and servo 2 has to be the same as distance between servo 2 and servo 3
-length of the parts is not very important
I think that everyone here know how to connect servos to the arduino so I will not describe it.
Arduino code:
Code:#include <Servo.h>
#define led0 13
#define Servo1Pin 17
#define Servo2Pin 18
#define Servo3Pin 19
Servo servo1;
Servo servo2;
Servo servo3;
byte s1=90;
byte s2=90;
byte s3=90;
byte DELAY=10;
boolean inProgress=false;
//#include <LiquidCrystal.h>
//LiquidCrystal lcd(12, 8, 7, 6, 5, 4, 2);
void setup()
{
// lcd.begin(16,2);
Serial.begin(9600);
pinMode(led0,OUTPUT);
attachServos();
}
void loop()
{
digitalWrite(led0,inProgress);
if(Serial.available())
{
if (Serial.read()==0xAA)
{
do{
}
while(Serial.available()<=4);
//serwa
s1=Serial.read();
s2=Serial.read();
s3=Serial.read();
DELAY=Serial.read();
inProgress=true;
}
}
if (servo1.read()>s1) servo1.write(servo1.read()-1);
if (servo1.read()<s1) servo1.write(servo1.read()+1);
if (servo2.read()>s2) servo2.write(servo2.read()-1);
if (servo2.read()<s2) servo2.write(servo2.read()+1);
if (servo3.read()>s3) servo3.write(servo3.read()-1);
if (servo3.read()<s3) servo3.write(servo3.read()+1);
if (inProgress==true && servo1.read()==s1 && servo2.read()==s2 && servo3.read()==s3)
{
Serial.print(1,BYTE);
inProgress=false;
}
delay(DELAY);
/*
lcd.clear();
lcd.print(servo1.read(),DEC);
lcd.print("-");
lcd.print(s1,DEC);
lcd.print(" ");
lcd.print(servo2.read(),DEC);
lcd.print("-");
lcd.print(s2,DEC);
lcd.setCursor(0,1);
lcd.print(servo3.read(),DEC);
lcd.print("-");
lcd.print(s3,DEC);
lcd.print(" ");
lcd.print(DELAY,DEC);
lcd.print(" ");
*/
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void attachServos()
{
servo1.attach(Servo1Pin);
servo2.attach(Servo2Pin);
servo3.attach(Servo3Pin);
}
and finally the PC software is here:
http://ezio.ovh.org/pliki/arm_plotter.rarThere is a file "settings.txt". You can set up and down limit of the servos to avoid destroy your arm.