![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Using capacitive touch sensor to control servo speed. Using NMHU Shield.
Fork of servo_control_shield_v1 by
main.cpp@0:6138ceae43f5, 2015-03-12 (annotated)
- Committer:
- bomalley
- Date:
- Thu Mar 12 18:31:10 2015 +0000
- Revision:
- 0:6138ceae43f5
- Child:
- 1:9d15bcabb1f2
Servo control for shield NMHU (New Mexico Highlands University) KL-46Z.; This will control two servos. at the same time back and forth.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bomalley | 0:6138ceae43f5 | 1 | #include "mbed.h" |
bomalley | 0:6138ceae43f5 | 2 | #include "Servo.h" |
bomalley | 0:6138ceae43f5 | 3 | |
bomalley | 0:6138ceae43f5 | 4 | #define WAITTIME 0.2 |
bomalley | 0:6138ceae43f5 | 5 | |
bomalley | 0:6138ceae43f5 | 6 | /* |
bomalley | 0:6138ceae43f5 | 7 | * Written by: Bresdin O'Malley 2015 |
bomalley | 0:6138ceae43f5 | 8 | * Servo control for shield NMHU (New Mexico Highlands University) KL-46Z. |
bomalley | 0:6138ceae43f5 | 9 | * This will control two servos. |
bomalley | 0:6138ceae43f5 | 10 | |
bomalley | 0:6138ceae43f5 | 11 | */ |
bomalley | 0:6138ceae43f5 | 12 | |
bomalley | 0:6138ceae43f5 | 13 | Servo myservo1(PTC9); |
bomalley | 0:6138ceae43f5 | 14 | Servo myservo2(PTC8); |
bomalley | 0:6138ceae43f5 | 15 | |
bomalley | 0:6138ceae43f5 | 16 | int main() { |
bomalley | 0:6138ceae43f5 | 17 | while(true) { |
bomalley | 0:6138ceae43f5 | 18 | for(float p=0; p<1.0; p += 0.1) { |
bomalley | 0:6138ceae43f5 | 19 | myservo1.write(p); |
bomalley | 0:6138ceae43f5 | 20 | myservo2.write(p); |
bomalley | 0:6138ceae43f5 | 21 | wait(WAITTIME); |
bomalley | 0:6138ceae43f5 | 22 | } |
bomalley | 0:6138ceae43f5 | 23 | } |
bomalley | 0:6138ceae43f5 | 24 | } |