a

Dependents:   3servotest 1stcomp 3rdcompfixstart 2ndcomp ... more

Fork of Servo by Tk A

Files at this revision

API Documentation at this revision

Comitter:
choutin
Date:
Wed Sep 07 09:40:58 2016 +0000
Parent:
0:655e1fcb96be
Child:
2:442fae3b1c0e
Child:
3:c112df463a8d
Commit message:
a

Changed in this revision

servo.cpp Show annotated file Show diff for this revision Revisions of this file
servo.h Show annotated file Show diff for this revision Revisions of this file
--- a/servo.cpp	Wed Sep 07 07:35:46 2016 +0000
+++ b/servo.cpp	Wed Sep 07 09:40:58 2016 +0000
@@ -2,9 +2,43 @@
 
 PwmOut pwmarm(PC_6);
 PwmOut pwmhand(PC_8);
-
+PwmOut pwmbelt(PC_9);
 float PERIOD=20000;
 
+void armdegree(int degree) {
+    int i;
+
+   pwmarm.period_ms(20);        //20ms
+   
+       degree=10;
+
+       i=500+degree*1900/180;
+       pwmarm.write(i/PERIOD); 
+}
+
+void handdegree(int degree) {
+    int i;
+
+   pwmarm.period_ms(20);        //20ms
+   
+       degree=10;
+
+       i=500+degree*1900/180;
+       pwmhand.write(i/PERIOD); 
+       
+}
+
+void beltdegree(int degree) {
+    int i;
+
+   pwmarm.period_ms(20);        //20ms
+   
+       degree=10;
+
+       i=500+degree*1900/180;
+       pwmbelt.write(i/PERIOD); 
+       
+}
 void close_hand(void) {
      int i,degree;
 
--- a/servo.h	Wed Sep 07 07:35:46 2016 +0000
+++ b/servo.h	Wed Sep 07 09:40:58 2016 +0000
@@ -6,4 +6,10 @@
 
 void open_hand(void);
 
-void open_arm(void);
\ No newline at end of file
+void open_arm(void);
+
+void armdegree(int degree);
+
+void handdegree(int degree);
+
+void beltdegree(int degree);
\ No newline at end of file