James Hilder / Mbed 2 deprecated PR_RobotArm

Dependencies:   RobotArmController SerialHalfDuplex mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "robotarm.h"
00002 
00003 Robotarm arm;
00004 
00005 int main()
00006 {
00007     wait(1); // Useful if you need to connect H-Term etc.
00008     //Run the main initialisation routine
00009     arm.init();
00010     //Reset the servos to center position (after 1 second delay)
00011     //NB This activates the servos (makes rigid) so be careful when using
00012     arm.zero_servos(1);
00013     //Wait till servos are zeroed
00014     wait(3);
00015     //Initialise remote control
00016     if(REMOTE_ENABLED == 1)remote.init();
00017     
00018     //User code can now go in a loop:
00019     while(1) {
00020         //Eg set all servos to 1948 then 2148
00021           servo.SetGoal(BASE,1948,1);
00022           servo.SetGoal(SHOULDER,1948,1);
00023           servo.SetGoal(ELBOW,1948,1);
00024           servo.SetGoal(WRIST,400,1);
00025             //If you want to show detailed info about a servo over serial, use the following:
00026             //servo.DebugData(WRIST);
00027           wait(0.5);
00028           servo.SetGoal(BASE,2148,1);
00029           servo.SetGoal(SHOULDER,2148,1);
00030           servo.SetGoal(ELBOW,2148,1);
00031           servo.SetGoal(WRIST,600,1);
00032           wait(0.5);
00033             //Alternatively we can set all the servos then use trigger - observe the difference...
00034             //servo.SetGoal(BASE,2148,0);
00035             //servo.SetGoal(SHOULDER,2148,0);
00036             //servo.SetGoal(ELBOW,2148,0);
00037             //servo.SetGoal(WRIST,600,0);
00038             //servo.trigger();
00039             //wait(0.5);
00040     }
00041 }