lighthouse

Dependencies:   RobotArmController SerialHalfDuplex mbed

Fork of PR_RobotArm by James Hilder

Committer:
jah128
Date:
Thu Feb 16 23:58:59 2017 +0000
Revision:
0:ba8a9d66892d
Child:
2:55f39e7883a6
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:ba8a9d66892d 1 #include "robotarm.h"
jah128 0:ba8a9d66892d 2
jah128 0:ba8a9d66892d 3 Robotarm arm;
jah128 0:ba8a9d66892d 4
jah128 0:ba8a9d66892d 5 int main()
jah128 0:ba8a9d66892d 6 {
jah128 0:ba8a9d66892d 7 wait(1); // Useful if you need to connect H-Term etc.
jah128 0:ba8a9d66892d 8 //Run the main initialisation routine
jah128 0:ba8a9d66892d 9 arm.init();
jah128 0:ba8a9d66892d 10 //Reset the servos to center position (after 1 second delay)
jah128 0:ba8a9d66892d 11 //NB This activates the servos (makes rigid) so be careful when using
jah128 0:ba8a9d66892d 12 arm.zero_servos(1);
jah128 0:ba8a9d66892d 13 //Wait till servos are zeroed
jah128 0:ba8a9d66892d 14 wait(3);
jah128 0:ba8a9d66892d 15 //Initialise remote control
jah128 0:ba8a9d66892d 16 if(REMOTE_ENABLED == 1)remote.init();
jah128 0:ba8a9d66892d 17
jah128 0:ba8a9d66892d 18 //User code can now go in a loop:
jah128 0:ba8a9d66892d 19 while(1) {
jah128 0:ba8a9d66892d 20 //Eg set all servos to 1948 then 2148
jah128 0:ba8a9d66892d 21 servo.SetGoal(BASE,1948,1);
jah128 0:ba8a9d66892d 22 servo.SetGoal(SHOULDER,1948,1);
jah128 0:ba8a9d66892d 23 servo.SetGoal(ELBOW,1948,1);
jah128 0:ba8a9d66892d 24 servo.SetGoal(WRIST,400,1);
jah128 0:ba8a9d66892d 25 //If you want to show detailed info about a servo over serial, use the following:
jah128 0:ba8a9d66892d 26 //servo.DebugData(WRIST);
jah128 0:ba8a9d66892d 27 wait(0.5);
jah128 0:ba8a9d66892d 28 servo.SetGoal(BASE,2148,1);
jah128 0:ba8a9d66892d 29 servo.SetGoal(SHOULDER,2148,1);
jah128 0:ba8a9d66892d 30 servo.SetGoal(ELBOW,2148,1);
jah128 0:ba8a9d66892d 31 servo.SetGoal(WRIST,600,1);
jah128 0:ba8a9d66892d 32 wait(0.5);
jah128 0:ba8a9d66892d 33 //Alternatively we can set all the servos then use trigger - observe the difference...
jah128 0:ba8a9d66892d 34 //servo.SetGoal(BASE,2148,0);
jah128 0:ba8a9d66892d 35 //servo.SetGoal(SHOULDER,2148,0);
jah128 0:ba8a9d66892d 36 //servo.SetGoal(ELBOW,2148,0);
jah128 0:ba8a9d66892d 37 //servo.SetGoal(WRIST,600,0);
jah128 0:ba8a9d66892d 38 //servo.trigger();
jah128 0:ba8a9d66892d 39 //wait(0.5);
jah128 0:ba8a9d66892d 40 }
jah128 0:ba8a9d66892d 41 }