![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
The servo version of SCRIBE
Dependencies: BLE_nRF8001 BNO055 HC_SR04_Ultrasonic_Library mbed-rtos mbed
Fork of SCRIBE_stepper by
servo.cpp@6:91ff95c9a44e, 2016-05-04 (annotated)
- Committer:
- nibab
- Date:
- Wed May 04 23:32:45 2016 +0000
- Revision:
- 6:91ff95c9a44e
- Child:
- 8:4d7b2dbdb694
The servo version. Delete stepper.h and stepper.cpp. Add servo.h and servo.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nibab | 6:91ff95c9a44e | 1 | #include "mbed.h" |
nibab | 6:91ff95c9a44e | 2 | |
nibab | 6:91ff95c9a44e | 3 | PwmOut pin25(p25); |
nibab | 6:91ff95c9a44e | 4 | PwmOut pin26(p26); |
nibab | 6:91ff95c9a44e | 5 | |
nibab | 6:91ff95c9a44e | 6 | void servo_reset(){ |
nibab | 6:91ff95c9a44e | 7 | pin25.period_ms(20); //Set the period: 20ms |
nibab | 6:91ff95c9a44e | 8 | pin26.period_ms(20); //Set the period: 20ms |
nibab | 6:91ff95c9a44e | 9 | } |
nibab | 6:91ff95c9a44e | 10 | |
nibab | 6:91ff95c9a44e | 11 | void servo_f(){ |
nibab | 6:91ff95c9a44e | 12 | pin25.pulsewidth_us(1300); |
nibab | 6:91ff95c9a44e | 13 | pin26.pulsewidth_us(1700); |
nibab | 6:91ff95c9a44e | 14 | } |
nibab | 6:91ff95c9a44e | 15 | |
nibab | 6:91ff95c9a44e | 16 | void servo_b(){ |
nibab | 6:91ff95c9a44e | 17 | pin25.pulsewidth_us(1700); |
nibab | 6:91ff95c9a44e | 18 | pin26.pulsewidth_us(1300); |
nibab | 6:91ff95c9a44e | 19 | } |
nibab | 6:91ff95c9a44e | 20 | |
nibab | 6:91ff95c9a44e | 21 | void servo_right(){ |
nibab | 6:91ff95c9a44e | 22 | pin25.pulsewidth_us(1700); |
nibab | 6:91ff95c9a44e | 23 | pin26.pulsewidth_us(1700); |
nibab | 6:91ff95c9a44e | 24 | } |
nibab | 6:91ff95c9a44e | 25 | |
nibab | 6:91ff95c9a44e | 26 | void servo_left(){ |
nibab | 6:91ff95c9a44e | 27 | pin25.pulsewidth_us(1300); |
nibab | 6:91ff95c9a44e | 28 | pin26.pulsewidth_us(1300); |
nibab | 6:91ff95c9a44e | 29 | } |
nibab | 6:91ff95c9a44e | 30 | |
nibab | 6:91ff95c9a44e | 31 | void servo_stop(){ |
nibab | 6:91ff95c9a44e | 32 | pin25.pulsewidth_us(1500); |
nibab | 6:91ff95c9a44e | 33 | pin26.pulsewidth_us(1515); |
nibab | 6:91ff95c9a44e | 34 | } |