bewegen van motor bij indrukken van knopje

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
arunr
Date:
Tue Oct 13 13:32:04 2015 +0000
Commit message:
Motor bewegen, werkt maar op ??n snelheid

Changed in this revision

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
diff -r 000000000000 -r 037c49ea92e2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 13 13:32:04 2015 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+
+    
+DigitalOut motor_direction(D4);
+PwmOut motor_speed(D5);
+ 
+DigitalIn button_1(PTC6); //counterclockwise
+DigitalIn button_2(PTA4); //clockwise
+ 
+ 
+const int pressed = 0;
+ 
+ 
+void move_motor_ccw (){
+    motor_direction = 0;
+    motor_speed = 1;
+    }
+    
+void move_motor_cw (){
+    motor_direction = 1;
+    motor_speed = 0.1;
+    }
+ 
+int main()
+{
+    
+    while (true) {
+     
+        if (button_1 == pressed){
+            move_motor_cw ();
+            }
+        else if (button_2 == pressed){
+            move_motor_ccw ();
+            }
+        else { 
+            motor_speed = 0;
+            }
+        
+    }
+}
diff -r 000000000000 -r 037c49ea92e2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 13 13:32:04 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file