![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
10/15/14 code
main.cpp@0:fbe913f85d70, 2014-10-15 (annotated)
- Committer:
- alphasig
- Date:
- Wed Oct 15 19:19:40 2014 +0000
- Revision:
- 0:fbe913f85d70
actual code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alphasig | 0:fbe913f85d70 | 1 | #include "mbed.h" |
alphasig | 0:fbe913f85d70 | 2 | #include "Servo.h" |
alphasig | 0:fbe913f85d70 | 3 | |
alphasig | 0:fbe913f85d70 | 4 | Servo myservo1(p21); |
alphasig | 0:fbe913f85d70 | 5 | Servo myservo2(p22); |
alphasig | 0:fbe913f85d70 | 6 | |
alphasig | 0:fbe913f85d70 | 7 | |
alphasig | 0:fbe913f85d70 | 8 | DigitalIn sw1(p16); |
alphasig | 0:fbe913f85d70 | 9 | DigitalIn sw2(p17); |
alphasig | 0:fbe913f85d70 | 10 | DigitalIn sw3(p18); |
alphasig | 0:fbe913f85d70 | 11 | DigitalIn sw4(p19); |
alphasig | 0:fbe913f85d70 | 12 | |
alphasig | 0:fbe913f85d70 | 13 | int switch1=sw1; |
alphasig | 0:fbe913f85d70 | 14 | int switch2=sw2; |
alphasig | 0:fbe913f85d70 | 15 | int switch3=sw3; |
alphasig | 0:fbe913f85d70 | 16 | int switch4=sw4; |
alphasig | 0:fbe913f85d70 | 17 | |
alphasig | 0:fbe913f85d70 | 18 | int main() { |
alphasig | 0:fbe913f85d70 | 19 | |
alphasig | 0:fbe913f85d70 | 20 | float servopos; |
alphasig | 0:fbe913f85d70 | 21 | |
alphasig | 0:fbe913f85d70 | 22 | while (switch1==1) |
alphasig | 0:fbe913f85d70 | 23 | { |
alphasig | 0:fbe913f85d70 | 24 | while (servopos <=.6) |
alphasig | 0:fbe913f85d70 | 25 | { |
alphasig | 0:fbe913f85d70 | 26 | myservo1= servopos; |
alphasig | 0:fbe913f85d70 | 27 | servopos=servopos +.005; |
alphasig | 0:fbe913f85d70 | 28 | wait(.01); |
alphasig | 0:fbe913f85d70 | 29 | } |
alphasig | 0:fbe913f85d70 | 30 | while (servopos >=.3) |
alphasig | 0:fbe913f85d70 | 31 | { |
alphasig | 0:fbe913f85d70 | 32 | myservo1=servopos; |
alphasig | 0:fbe913f85d70 | 33 | servopos=servopos-.005; |
alphasig | 0:fbe913f85d70 | 34 | wait(.01); |
alphasig | 0:fbe913f85d70 | 35 | } |
alphasig | 0:fbe913f85d70 | 36 | } |
alphasig | 0:fbe913f85d70 | 37 | } |