Tomohiro Aoki / Mbed 2 deprecated control_stick

Dependencies:   mbed QEI

Files at this revision

API Documentation at this revision

Comitter:
Tomo1213
Date:
Sat Jul 27 09:34:10 2019 +0000
Commit message:
first commit

Changed in this revision

QEI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Sat Jul 27 09:34:10 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/aberk/code/QEI/#5c2ad81551aa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jul 27 09:34:10 2019 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+#include "QEI.h"
+
+PwmOut MD_PWMB(PB_1);
+DigitalOut MD_BIN1(PA_10),MD_BIN2(PA_12);
+
+BusIn Encoder_PullUp(PA_8,PA_9);
+QEI Encoder(PA_9,PA_8,NC,12,QEI::X4_ENCODING);
+
+
+void motor(float speed){
+    
+    float speed_f;
+    MD_PWMB.period_us(50);
+    speed_f = fabsf(speed);
+
+    if(speed < 0){
+        MD_PWMB = speed_f;
+        MD_BIN1 = 1;
+        MD_BIN2 = 0; 
+    }
+    else if(0 < speed && speed <= 1){
+        MD_PWMB = speed_f;
+        MD_BIN1 = 0;
+        MD_BIN2 = 1;
+    }
+    else{
+        MD_PWMB = 1;
+        MD_BIN1 = 0;
+        MD_BIN2 = 0;
+    }
+    
+}
+
+int main(){
+    
+    Encoder_PullUp.mode(PullUp);
+    
+    while(1){
+    
+       printf("%d\r\n",Encoder.getPulses());
+    
+    }
+ 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jul 27 09:34:10 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file