Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: RobotArmController SerialHalfDuplex mbed
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 }
Generated on Sun Jul 31 2022 15:12:23 by
1.7.2