Dependencies:   Servo mbed

Fork of ReedSwitch by Gerardo Espinoza

Revision:
1:edc70fba9d80
Parent:
0:73919552e1de
--- a/main.cpp	Sat Dec 14 18:01:16 2013 +0000
+++ b/main.cpp	Sat Aug 08 18:24:48 2015 +0000
@@ -1,32 +1,33 @@
 #include "mbed.h"
 #include "Servo.h"
 
-DigitalIn rSwitch(D10);
-Servo servoRotado(D11);
+Servo myservo(p21);
 
-int valSwitch;
-float pos=0;
+DigitalIn pb(p5);
+DigitalIn pb1(p6);
+int button1=0;
+int button2=0;
+float servo=0;
+
+// SPST Pushbutton demo using internal PullUp function
+// no external PullUp resistor needed
+// Pushbutton from P8 to GND.
 
 int main() {
-    rSwitch.mode(PullUp);
-    servoRotado.calibrate(0.001, 45.0);
-    while(1) {
-       valSwitch=rSwitch;
+myservo=0;
+pb.mode(PullUp);
+pb1.mode(PullUp);
 
-       while(pos<=1 and valSwitch==1){
-        valSwitch=rSwitch;
-        pos=pos+0.05;
-        servoRotado=pos;
-        wait(0.3);
-       }
-       while(pos>=0){
-        pos=pos-0.05;
-        servoRotado=pos;
-        wait(0.3);
-       }
-        
-            
-        
-                
-    }
+while(1) {
+if(pb==0)
+{
+myservo = myservo+0.1;
+wait(0.2);
 }
+else if(pb1==0)
+{
+myservo=myservo-0.1;
+wait(0.2);
+}
+}
+}
\ No newline at end of file