Servo controller

Dependencies:   Servo mbed

Revision:
0:1810c6beabf5
diff -r 000000000000 -r 1810c6beabf5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 20 09:34:24 2017 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "Servo.h"
+
+//------------------------------------------------------------------------------
+//------------------------------Servo Setup-------------------------------------
+//------------------------------------------------------------------------------
+
+Servo MyServo(D9);
+InterruptIn But1(PTA4);
+int k=0;
+
+//------------------------------------------------------------------------------
+//---------------------------Servo Controller-----------------------------------
+//------------------------------------------------------------------------------
+
+void servo_control (){
+    if (k==0){
+        MyServo = 0;
+        k=1;
+    }
+    else{
+        MyServo = 2;
+        k=0;
+        }
+}
+
+//------------------------------------------------------------------------------
+//-------------------------------Main Loop--------------------------------------
+//------------------------------------------------------------------------------
+
+int main()
+{
+    But1.rise(&servo_control);
+    while (1) {}
+}
\ No newline at end of file