6.1 Servo Richtung, Tasten links, rechts.

Dependencies:   Servo mbed

Fork of 06-01-Uebung by th.iotkit1.ch

Revision:
0:eca1d20dbffa
Child:
1:41961321aa61
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 04 16:11:42 2015 +0000
@@ -0,0 +1,25 @@
+/** 6.1 Servo Richtung, Tasten links, rechts.
+    Anwendung: Roboterarm bewegen.
+*/
+#include "mbed.h"
+#include "Servo.h"
+
+DigitalIn button1( PTC9 );
+DigitalIn button2( PTC0 );
+
+Servo servo1 ( A5 );
+
+int main()
+{
+    // Mittelstellung
+    servo1 = 0.5f;
+    
+    while (true) 
+    {
+        if  ( button1 == 0 && servo1.read() > 0.0f )
+            servo1 = servo1.read() - 0.01f;
+        if  ( button2 == 0 && servo1.read() < 1.0f )
+            servo1 = servo1.read() + 0.01f;
+        wait(0.2f);
+    }
+}
\ No newline at end of file