Presentation code for PROJECT #1 - ES200 Fall 2014
Dependencies: Servo mbed Motor
Diff: ARM/armmain.cpp
- Revision:
- 2:f10d71467f13
diff -r 369072696874 -r f10d71467f13 ARM/armmain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ARM/armmain.cpp Thu Oct 09 19:16:54 2014 +0000 @@ -0,0 +1,43 @@ +//Code for the arm servo +//Created 09 OCT 14, 3/C Stabler +#include "mbed.h" +#include "Servo.h" + +Servo arm(p21); +DigitalIn switch1(p16); +DigitalIn switch2(p17); + +int main(){ + + float armpos; + int sw1; + int sw2; + + while(1){ + sw1 = switch1.read(); + sw2 = switch2.read(); + + if(sw1 == 1) + { + for(armpos = 0.0; armpos <= 1.0; armpos += .05){ + arm = armpos; + wait(.1); + } + } + else if(sw1 == 0) + { + arm = armpos; + } + else if(sw2 == 1) + { + for(armpos = 0.0; armpos >= 0.0; armpos -= .05){ + arm = armpos; + wait(.1); + } + } + else if(sw2 == 0) + { + arm = armpos; + } + } +} \ No newline at end of file