flja;lsgjv;l kj

Dependents:   ARAI45th

Files at this revision

API Documentation at this revision

Comitter:
sakanakuuun
Date:
Wed Sep 07 07:35:46 2016 +0000
Commit message:
afkopajvf;l

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/servo.cpp	Wed Sep 07 07:35:46 2016 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+
+PwmOut pwmarm(PC_6);
+PwmOut pwmhand(PC_8);
+
+float PERIOD=20000;
+
+void close_hand(void) {
+     int i,degree;
+
+    pwmhand.period_ms(20);        //20ms
+    
+        degree=175;
+
+        i=500+degree*1900/180;
+        pwmhand.pulsewidth_us(i); 
+        
+        
+}
+
+void close_arm(void) {
+    int i,degree;
+
+   pwmarm.period_ms(20);        //20ms
+   
+       degree=160;
+
+       i=500+degree*1900/180;
+       pwmarm.write(i/PERIOD); 
+       
+       
+}
+
+
+void open_hand(void) {
+    int i,degree;
+
+   pwmhand.period_ms(20);        //20ms
+   
+       degree=90;
+
+       i=500+degree*1900/180;
+       pwmhand.write(i/PERIOD); 
+       
+       
+}
+
+
+
+void open_arm(void) {
+    int i,degree;
+
+   pwmarm.period_ms(20);        //20ms
+   
+       degree=10;
+
+       i=500+degree*1900/180;
+       pwmarm.write(i/PERIOD); 
+       
+       
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/servo.h	Wed Sep 07 07:35:46 2016 +0000
@@ -0,0 +1,9 @@
+#include "mbed.h"
+
+void close_hand(void);
+
+void close_arm(void);
+
+void open_hand(void);
+
+void open_arm(void);
\ No newline at end of file