Convert the pwm signal generated by reciever into a signal used by H-bridge

Dependencies:   PwmIn mbed

Files at this revision

API Documentation at this revision

Comitter:
fy17y2w
Date:
Mon May 06 21:24:22 2019 +0000
Commit message:
N/A

Changed in this revision

PwmIn.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/PwmIn.lib	Mon May 06 21:24:22 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/PwmIn/#6d68eb9b6bbb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 06 21:24:22 2019 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "PwmIn.h"
+
+
+Timer t;
+PwmOut      white_up(PC_8),white_down(PC_9),gray_up(PC_6),gray_down(PB_8);
+PwmIn lin(A0),rin(A1);
+int main()
+{
+    white_up.period_ms(2.5);
+    white_down.period_ms(2.5);
+    gray_up.period_ms(2.5);
+    gray_down.period_ms(2.5);
+    while(1){
+        if(lin.dutycycle()<0.59 ){
+         gray_down.write(-(lin.dutycycle()-0.59)*4.34);
+         wait_ms(10);
+         }
+         else if(lin.dutycycle()>0.61){
+             white_down.write((lin.dutycycle()-0.61)*4.54 );
+             wait_ms(10);
+             }
+             else{
+                 white_down.write(0);
+                 gray_down.write(0);
+                 wait_ms(10);
+                 }
+        if(rin.dutycycle()< 0.59){
+         gray_up.write(-(rin.dutycycle()-0.59)*4.34  );
+         wait_ms(10);
+         }
+         else if(rin.dutycycle()>0.61){
+             white_up.write((rin.dutycycle()-0.61)*4.34 );
+             wait_ms(10);
+             }
+             else{
+                 white_up.write(0);
+                 gray_up.write(0);
+                 wait_ms(10);
+                 }
+        }
+                 
+             
+         
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 06 21:24:22 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file