Guardians of the Galaxy
/
armcode
code for the RC motor on arm
Fork of testrcmotor by
Diff: main.cpp
- Revision:
- 1:a750fbe3305c
- Parent:
- 0:88d8a50a003e
--- a/main.cpp Thu Oct 09 18:01:03 2014 +0000 +++ b/main.cpp Thu Oct 16 18:53:13 2014 +0000 @@ -1,24 +1,37 @@ +//Code for the arm servo +//Created 09 OCT 14, 3/C Stabler +//Revised: +// 16 OCT- Code works, needs smoothing out #include "mbed.h" #include "Servo.h" -Servo dylan1(p21); -DigitalIn sw1(p16); +Servo arm(p21); +DigitalIn sw1(p16); //up +DigitalIn sw2(p17); //down + +int main(){ -int main() -{ - float servopos; - while (1) { - if (sw1 == 1) { - for (servopos = 0; servopos <= 1.0; servopos += 1.0) { - dylan1 = servopos; - } - wait (1); - } else if (sw1 == 0) { - for (servopos = 1.0; servopos >= 0; servopos -=1.0) { - dylan1 = servopos; - } - wait (1); + float armpos; + + while(1){ + + if((sw1 == 1) && (sw2 == 0)){ + armpos += .05; + arm = armpos; + wait(.1); + } + else if((sw1 == 0) && (sw2 == 0)){ + arm = armpos; + wait(.1); + } + if((sw2 == 1) && (sw1 == 0)){ + armpos -= .01; + arm = armpos; + wait(.05); + } + else if((sw2 == 0) && (sw1 == 0)){ + arm = armpos; + wait(.1); } } -} - +} \ No newline at end of file