Gets user Input to turn the servo to certain degrees
servo.cpp@2:9d9717796ab2, 2019-01-13 (annotated)
- Committer:
- hzelayasolano22
- Date:
- Sun Jan 13 21:57:11 2019 +0000
- Revision:
- 2:9d9717796ab2
- Child:
- 3:5b6a55afc60a
servo.cpp for Lab almost done
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hzelayasolano22 | 2:9d9717796ab2 | 1 | #include "servo.h" |
hzelayasolano22 | 2:9d9717796ab2 | 2 | PwmOut servo(p21); |
hzelayasolano22 | 2:9d9717796ab2 | 3 | |
hzelayasolano22 | 2:9d9717796ab2 | 4 | void setServo(); |
hzelayasolano22 | 2:9d9717796ab2 | 5 | servo.period(0.020); |
hzelayasolano22 | 2:9d9717796ab2 | 6 | servo.pulsewidth_us(1500); |
hzelayasolano22 | 2:9d9717796ab2 | 7 | wait(2); |
hzelayasolano22 | 2:9d9717796ab2 | 8 | } |
hzelayasolano22 | 2:9d9717796ab2 | 9 | |
hzelayasolano22 | 2:9d9717796ab2 | 10 | void moveServo(char a){ |
hzelayasolano22 | 2:9d9717796ab2 | 11 | switch(a){ |
hzelayasolano22 | 2:9d9717796ab2 | 12 | case 1: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 13 | case 2: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 14 | case 3: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 15 | case 4: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 16 | case 4: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 17 | case 5: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 18 | case 6: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 19 | case 7: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 20 | case 8: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 21 | case 9: servo.pulsdewidth_us(pulsewidth(-90)); break; |
hzelayasolano22 | 2:9d9717796ab2 | 22 | } |
hzelayasolano22 | 2:9d9717796ab2 | 23 | |
hzelayasolano22 | 2:9d9717796ab2 | 24 | |
hzelayasolano22 | 2:9d9717796ab2 | 25 | |
hzelayasolano22 | 2:9d9717796ab2 | 26 | } |