![](/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@14:82248fb06e53, 2016-05-12 (annotated)
- Committer:
- manz
- Date:
- Thu May 12 06:17:49 2016 +0000
- Revision:
- 14:82248fb06e53
- Parent:
- 13:d49cb8b52a1e
latest version;
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(){ |
manz | 14:82248fb06e53 | 12 | //pin25.pulsewidth_us(1300); |
manz | 14:82248fb06e53 | 13 | //pin26.pulsewidth_us(1700); |
manz | 14:82248fb06e53 | 14 | pin25.pulsewidth_us(1350); |
manz | 14:82248fb06e53 | 15 | pin26.pulsewidth_us(1650); |
nibab | 6:91ff95c9a44e | 16 | } |
nibab | 6:91ff95c9a44e | 17 | |
nibab | 6:91ff95c9a44e | 18 | void servo_b(){ |
nibab | 6:91ff95c9a44e | 19 | pin25.pulsewidth_us(1700); |
nibab | 6:91ff95c9a44e | 20 | pin26.pulsewidth_us(1300); |
nibab | 6:91ff95c9a44e | 21 | } |
nibab | 6:91ff95c9a44e | 22 | |
nibab | 6:91ff95c9a44e | 23 | void servo_right(){ |
nibab | 6:91ff95c9a44e | 24 | pin25.pulsewidth_us(1700); |
nibab | 6:91ff95c9a44e | 25 | pin26.pulsewidth_us(1700); |
nibab | 6:91ff95c9a44e | 26 | } |
nibab | 6:91ff95c9a44e | 27 | |
nibab | 6:91ff95c9a44e | 28 | void servo_left(){ |
nibab | 6:91ff95c9a44e | 29 | pin25.pulsewidth_us(1300); |
nibab | 6:91ff95c9a44e | 30 | pin26.pulsewidth_us(1300); |
nibab | 6:91ff95c9a44e | 31 | } |
nibab | 6:91ff95c9a44e | 32 | |
nibab | 6:91ff95c9a44e | 33 | void servo_stop(){ |
nibab | 6:91ff95c9a44e | 34 | pin25.pulsewidth_us(1500); |
manz | 14:82248fb06e53 | 35 | pin26.pulsewidth_us(1515); |
nibab | 13:d49cb8b52a1e | 36 | } |
nibab | 13:d49cb8b52a1e | 37 | |
nibab | 13:d49cb8b52a1e | 38 | void servo_slowright(){ |
nibab | 13:d49cb8b52a1e | 39 | pin25.pulsewidth_us(1550); |
nibab | 13:d49cb8b52a1e | 40 | pin26.pulsewidth_us(1550); |
nibab | 13:d49cb8b52a1e | 41 | } |
nibab | 13:d49cb8b52a1e | 42 | |
nibab | 13:d49cb8b52a1e | 43 | void servo_slowleft(){ |
nibab | 13:d49cb8b52a1e | 44 | pin25.pulsewidth_us(1450); |
nibab | 13:d49cb8b52a1e | 45 | pin26.pulsewidth_us(1450); |
nibab | 6:91ff95c9a44e | 46 | } |