bewegen van motor bij indrukken van knopje

Dependencies:   mbed

Revision:
0:037c49ea92e2
--- /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;
+            }
+        
+    }
+}