While the do have sets prepared that just need assembling I have decided to go down a different path and selected the pieces I need to build my own little arm, I'm not experienced enough yet to simply pick out pieces and create something from scratch so I am using this arm as a template. I have had to reverse engineer it just using the picture to put together a parts list to order, I also have a rotating base on order too.
I have more of less finished the code I need to control the arm with potentiometers, there will be six in total with each controlling a degree of motion as listed below.
- Base
- Shoulder
- Elbow
- Wrist
- Grip Rotate
- Gripper
With the pots, servos and the LCD screen in use I have run out of space on my Arduino Uno, Its the perfect excuse I have been looking for to buy a Mega. however there will soon be another option available that I am getting very excited about and its this UDOO! Think of it as a Raspberry pi on steroids with a Arduino Due rammed down its throat for good measure. with a funding level of 1,600%+ on Kickstarter I think its safe to say lots of others also like the idea.
Last but not least if the code I am using, I have learned allot more but none of it really shows here, despite being written again from scratch this is still a modified version of the previous piece of code, the only difference being the extra two servo's and some variables being renamed.
I wont be adding colour to it tonight, it takes far to long and I want to get on and play a game of Supreme Commander. I will probably do it in the next few days in addition to posting something about the Arm too.
---
#include <LiquidCrystal.h>; //Activate the LCD libary
#include <Servo.h>; //Activate the Servo Libary
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //Tell the arduino which pins the lcd uses
Servo Grip; //Create servo names
Servo GripR;
Servo Wrist;
Servo Elbow;
Servo Shoulder;
Servo Base;
void setup () {
lcd.begin(16, 2); //Tell the arduino the lcd is 2 rows deep and 16 colums long
Grip.attach(6); //Attach Grip to pin #
GripR.attach(5); //Attach GripR to pin #
Wrist.attach(4); //Attach Wrist to pin #
Elbow.attach(3); //Attach Elbow to pin #
Shoulder.attach(2); //Attach shoulder to pin #
Base.attach(13); //Attach base to pin #
}
void loop () {
//Display number Identity
lcd.setCursor(4, 0); //Set lcd position to top left middle
lcd.print("<A"); //Print Pot ID <A
lcd.setCursor(10, 0); //Set lcd position to top right middle
lcd.print("B>"); //Print Pot ID B>
lcd.setCursor(4, 1); //Set lcd position to bottom left middle
lcd.print("<C"); //Print Pot ID <C
lcd.setCursor(10, 1); //Set lcd position to bottom right middle
lcd.print("D>"); //Print Pot ID D>
//Pot A read and print on LCD
int BasePot = analogRead(A0); //Read value from pin A0
BasePot = map(BasePot, 0, 1023, 0, 179); //Convert 0-1023 to 0-179 degrees
lcd.setCursor(0, 0); //Set lcd position to top left
lcd.print(BasePot); //Print value from A0 in degrees on lcd
//Pot B read and print on LCD
int ShoulderPot = analogRead(A1); //Read value from pin A1
ShoulderPot = map(ShoulderPot, 0, 1023, 0, 179); //Convert 0-1023 to 0-179 degrees
lcd.setCursor(13, 0); //Set lcd position to top right
lcd.print(ShoulderPot); //Print value from A1 in degrees on lcd
//Pot C read and print on LCD
int ElbowPot = analogRead(A2); //Read value from pin A2
ElbowPot = map(ElbowPot, 0, 1023, 0, 179); //Convert 0-1023 to 0-179 degrees
lcd.setCursor(0, 1); //Set lcd position to bottom left
lcd.print(ElbowPot); //Print value from A2 in degrees on lcd
//Pot D read and print on LCD
int WristPot = analogRead(A3); //Read value from pin A3
WristPot = map(WristPot, 0, 1023, 0, 179); //Convert 0-1023 to 0-179 degrees
lcd.setCursor(13, 1); //Set lcd position to bottom right
lcd.print(WristPot); //Print value from A3 in degrees on lcd
//Pot E read
int GripPot = analogRead(A4); //Read value from pin A3
GripPot = map(GripPot, 0, 1023, 0, 179); //Convert 0-1023 to 0-179 degrees
//Pot F read
int GripRPot = analogRead(A5); //Read value from pin A3
GripRPot = map(GripRPot, 0, 1023, 0, 179); //Convert 0-1023 to 0-179 degrees
//Servo Control
Base.write(BasePot); //sets servo A to position dictated by BasePot
Shoulder.write(ShoulderPot); //sets servo B to position dictated by ShoulderPot
Elbow.write(ElbowPot); //sets servo C to position dictated by ElbowPot
Wrist.write(WristPot); //sets servo D to position dictated by WristPot
Grip.write(GripPot); //sets servo C to position dictated by GripPot
GripR.write(GripRPot); //sets servo C to position dictated by GripPot
delay(10);
}
No comments:
Post a Comment