
Servo
main.cpp@0:07bff9917d0d, 2015-08-26 (annotated)
- Committer:
- facuramos
- Date:
- Wed Aug 26 15:30:54 2015 +0000
- Revision:
- 0:07bff9917d0d
Servo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
facuramos | 0:07bff9917d0d | 1 | #include "mbed.h" |
facuramos | 0:07bff9917d0d | 2 | #include "TSISensor.h" |
facuramos | 0:07bff9917d0d | 3 | |
facuramos | 0:07bff9917d0d | 4 | PwmOut servo(PTD5); |
facuramos | 0:07bff9917d0d | 5 | float t; |
facuramos | 0:07bff9917d0d | 6 | |
facuramos | 0:07bff9917d0d | 7 | int main() { |
facuramos | 0:07bff9917d0d | 8 | TSISensor tsi; |
facuramos | 0:07bff9917d0d | 9 | while(true) |
facuramos | 0:07bff9917d0d | 10 | { |
facuramos | 0:07bff9917d0d | 11 | t=(tsi.readPercentage()*0.002); |
facuramos | 0:07bff9917d0d | 12 | servo.period(0.020); //Periodo=20 mS |
facuramos | 0:07bff9917d0d | 13 | servo.pulsewidth(0.0005+t); //Hay que cambiar el ancho del pulso entre 1 y 2.5 mS para el Servo |
facuramos | 0:07bff9917d0d | 14 | wait(0.02); |
facuramos | 0:07bff9917d0d | 15 | |
facuramos | 0:07bff9917d0d | 16 | |
facuramos | 0:07bff9917d0d | 17 | } |
facuramos | 0:07bff9917d0d | 18 | } |
facuramos | 0:07bff9917d0d | 19 |