Pot da entrada analogica al KL25Z y salen 2 PWM a las entradas del puente H

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
alonsoangulo
Date:
Tue Dec 01 04:09:19 2015 +0000
Commit message:
Controlador motor DC primera forma

Changed in this revision

mbed.bld Show annotated file Show diff for this revision Revisions of this file
motordc1.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r d997692fa348 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 01 04:09:19 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file
diff -r 000000000000 -r d997692fa348 motordc1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motordc1.cpp	Tue Dec 01 04:09:19 2015 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+
+AnalogIn pot(PTB3);
+PwmOut IN1(PTD4);
+PwmOut IN2(PTA12);
+DigitalIn boton1(PTB2);
+DigitalIn boton2(PTB1);
+DigitalOut myled(LED1);
+
+int main() {
+        myled = 0;
+        wait(0.5);
+        myled = 1;
+        
+    while(1) {
+        if (boton1==0 && boton2==1){
+            float input = pot; 
+            IN1 = input; 
+            IN2 = 0;
+            wait(0.1); 
+        } else if(boton1==1 && boton2==0){
+            float input = pot; 
+            IN2 = input; 
+            IN1 = 0;
+            wait(0.1); 
+        } else if(boton1==1 && boton2==1){
+             IN1=0;
+             IN2=0;
+        } else if(boton1==0 && boton2==0){
+             IN1=0;
+             IN2=0;
+             }
+        
+        
+    }
+}