This program sets the position of the motor by taking input from switches

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
EduRemo
Date:
Fri Feb 05 07:32:01 2016 +0000
Commit message:
FRCRCE

Changed in this revision

Servo.lib Show annotated file Show diff for this revision Revisions of this file
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 9c4154e40f94 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Fri Feb 05 07:32:01 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 9c4154e40f94 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Feb 05 07:32:01 2016 +0000
@@ -0,0 +1,43 @@
+// Hello World to sweep a servo through its full range
+
+#include "mbed.h"
+#include "Servo.h"
+
+Servo myservo(PTC1);
+
+DigitalIn sw0(PTD1);  // Switch selected as input
+DigitalIn sw1(PTD3);
+DigitalIn sw2(PTD2);
+DigitalIn sw3(PTD0);
+
+int main() 
+{   
+    while(1) 
+    {
+          if (sw0==0 && sw1==1 && sw2==1 && sw3==1)
+          {
+              myservo = 99/100.0;
+              wait(0.5);
+          }
+          else if (sw0==1 && sw1==0 && sw2==1 && sw3==1)
+          {
+              myservo = 66/100.0;
+              wait(0.5);
+          }
+          else if (sw0==1 && sw1==1 && sw2==0 && sw3==1)
+          {
+              myservo = 33/100.0;
+              wait(0.5);
+          }
+          else if (sw0==1 && sw1==1 && sw2==1 && sw3==0)
+          {
+              myservo = 1/100.0;
+              wait(0.5);
+          }
+          else
+          {
+              myservo = 50/100.0;
+              wait(0.5);
+          }
+      }
+}
diff -r 000000000000 -r 9c4154e40f94 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 05 07:32:01 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32
\ No newline at end of file