Fa2018-es200-1112-proj2-rockemsockem
/
project2
Servo code
main.cpp@0:b00d475569de, 2018-10-09 (annotated)
- Committer:
- lugi_dugi
- Date:
- Tue Oct 09 13:41:48 2018 +0000
- Revision:
- 0:b00d475569de
Code for servo;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lugi_dugi | 0:b00d475569de | 1 | #include "mbed.h" |
lugi_dugi | 0:b00d475569de | 2 | #include "Servo.h" |
lugi_dugi | 0:b00d475569de | 3 | int main() { |
lugi_dugi | 0:b00d475569de | 4 | Servo myservo1(p21); |
lugi_dugi | 0:b00d475569de | 5 | Servo myservo2(p23); |
lugi_dugi | 0:b00d475569de | 6 | |
lugi_dugi | 0:b00d475569de | 7 | DigitalOut sw1(p20); |
lugi_dugi | 0:b00d475569de | 8 | DigitalOut sw2(p19); |
lugi_dugi | 0:b00d475569de | 9 | |
lugi_dugi | 0:b00d475569de | 10 | while (1) { |
lugi_dugi | 0:b00d475569de | 11 | |
lugi_dugi | 0:b00d475569de | 12 | |
lugi_dugi | 0:b00d475569de | 13 | myservo1.calibrate(0.0009, 90.0); |
lugi_dugi | 0:b00d475569de | 14 | myservo2.calibrate(0.0009, 90.0); |
lugi_dugi | 0:b00d475569de | 15 | |
lugi_dugi | 0:b00d475569de | 16 | while (sw1 = 1) { |
lugi_dugi | 0:b00d475569de | 17 | myservo1.write(0.0); |
lugi_dugi | 0:b00d475569de | 18 | myservo1.write(2.0); |
lugi_dugi | 0:b00d475569de | 19 | } |
lugi_dugi | 0:b00d475569de | 20 | |
lugi_dugi | 0:b00d475569de | 21 | while (sw2 = (1) ) { |
lugi_dugi | 0:b00d475569de | 22 | myservo2.write(0.0); |
lugi_dugi | 0:b00d475569de | 23 | myservo2.write(2.0); |
lugi_dugi | 0:b00d475569de | 24 | } |
lugi_dugi | 0:b00d475569de | 25 | } |
lugi_dugi | 0:b00d475569de | 26 | } |
lugi_dugi | 0:b00d475569de | 27 |