Manuel Sanchez
/
ServoPOF
Example program, usingthe Servo library
Fork of ServoProgram by
main.cpp@1:e5135330cd7a, 2017-08-16 (annotated)
- Committer:
- manuelmbed86
- Date:
- Wed Aug 16 19:54:35 2017 +0000
- Revision:
- 1:e5135330cd7a
- Parent:
- 0:7b3eabfa1a0f
Programa para uso de servo motor com placa KL25Z na porta A5/PTC1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:7b3eabfa1a0f | 1 | #include "mbed.h" |
simon | 0:7b3eabfa1a0f | 2 | #include "Servo.h" |
simon | 0:7b3eabfa1a0f | 3 | |
manuelmbed86 | 1:e5135330cd7a | 4 | Servo myservo(A5); |
simon | 0:7b3eabfa1a0f | 5 | Serial pc(USBTX, USBRX); |
simon | 0:7b3eabfa1a0f | 6 | |
simon | 0:7b3eabfa1a0f | 7 | float range = 0.0005; |
simon | 0:7b3eabfa1a0f | 8 | float position = 0.5; |
manuelmbed86 | 1:e5135330cd7a | 9 | int main() { |
manuelmbed86 | 1:e5135330cd7a | 10 | |
manuelmbed86 | 1:e5135330cd7a | 11 | while(1) { |
manuelmbed86 | 1:e5135330cd7a | 12 | for(int i=0; i<100; i++) { |
manuelmbed86 | 1:e5135330cd7a | 13 | myservo = i/100.0; |
manuelmbed86 | 1:e5135330cd7a | 14 | wait(0.05); |
manuelmbed86 | 1:e5135330cd7a | 15 | } |
manuelmbed86 | 1:e5135330cd7a | 16 | for(int i=100; i>0; i--) { |
manuelmbed86 | 1:e5135330cd7a | 17 | myservo = i/100.0; |
manuelmbed86 | 1:e5135330cd7a | 18 | wait(0.05); |
manuelmbed86 | 1:e5135330cd7a | 19 | } |
manuelmbed86 | 1:e5135330cd7a | 20 | } |
manuelmbed86 | 1:e5135330cd7a | 21 | } |
manuelmbed86 | 1:e5135330cd7a | 22 |