Shows the current positions of the 4 servos on the display...

Dependencies:   PR_RobotArmController mbed

Committer:
jah128
Date:
Fri Mar 03 13:38:24 2017 +0000
Revision:
0:c1930e7050d1
Initial commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:c1930e7050d1 1 #include "robotarm.h"
jah128 0:c1930e7050d1 2
jah128 0:c1930e7050d1 3 Robotarm arm;
jah128 0:c1930e7050d1 4
jah128 0:c1930e7050d1 5 int main()
jah128 0:c1930e7050d1 6 {
jah128 0:c1930e7050d1 7 //Run the main initialisation routine
jah128 0:c1930e7050d1 8 arm.init();
jah128 0:c1930e7050d1 9 display.clear_display();
jah128 0:c1930e7050d1 10 while(1) {
jah128 0:c1930e7050d1 11 int base = servo.GetPosition(BASE);
jah128 0:c1930e7050d1 12 int shoulder = servo.GetPosition(SHOULDER);
jah128 0:c1930e7050d1 13 int elbow = servo.GetPosition(ELBOW);
jah128 0:c1930e7050d1 14 int wrist = servo.GetPosition(WRIST);
jah128 0:c1930e7050d1 15 char s1[17];
jah128 0:c1930e7050d1 16 char s2[17];
jah128 0:c1930e7050d1 17 sprintf(s1,"B:%4d S:%4d",base,shoulder);
jah128 0:c1930e7050d1 18 sprintf(s2,"E:%4d W:%4d",elbow,wrist);
jah128 0:c1930e7050d1 19 display.set_position(0,0);
jah128 0:c1930e7050d1 20 display.write_string(s1);
jah128 0:c1930e7050d1 21 display.set_position(1,0);
jah128 0:c1930e7050d1 22 display.write_string(s2);
jah128 0:c1930e7050d1 23 wait(0.2);
jah128 0:c1930e7050d1 24 }
jah128 0:c1930e7050d1 25 }