1 sola salida de PWM del KL25Z para el Enable del puente H. 1 solo botón conectado a un NOT. La negación va al IN1 y la no negada va al IN2. Para que con un solo botón haya un control del giro del motor pero sin freno.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
alonsoangulo
Date:
Tue Dec 01 04:16:40 2015 +0000
Commit message:
Controlador motor DC tercera forma

Changed in this revision

mbed.bld Show annotated file Show diff for this revision Revisions of this file
motordc3.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 657fc6ce0791 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 01 04:16:40 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43
\ No newline at end of file
diff -r 000000000000 -r 657fc6ce0791 motordc3.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motordc3.cpp	Tue Dec 01 04:16:40 2015 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+AnalogIn pot(PTB3);
+PwmOut motordc(PTD4);
+DigitalIn boton(PTB2);
+DigitalOut IN1(PTD0);
+DigitalOut IN2(PTD5);
+DigitalOut myled(LED1);
+
+int main() {
+    
+    myled=0;
+    wait(0.5);
+    myled=1;
+
+        
+    while(1) {
+        
+        
+        if(boton==1){
+            float input = pot; 
+            motordc = input; 
+            IN1=1;
+            IN2=0;
+            wait(0.1);
+        } else if(boton==0){
+            float input = pot; 
+            motordc = input; 
+            IN1=0;
+            IN2=1;
+            wait(0.1);
+                
+                }
+    }
+}
\ No newline at end of file