PEDRO MATIZ
/
Proyectodeinvestigacion
CONTROL DE SERVOMOTOR POR BLUETOOTH
main.cpp@0:313c9277b9d9, 2017-10-07 (annotated)
- Committer:
- ABD931
- Date:
- Sat Oct 07 21:45:51 2017 +0000
- Revision:
- 0:313c9277b9d9
PROGRAMA DE CONTROL DE SERVOMOTOR POR BLUETOOHT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ABD931 | 0:313c9277b9d9 | 1 | #include "mbed.h" |
ABD931 | 0:313c9277b9d9 | 2 | #include "SoftSerial.h" |
ABD931 | 0:313c9277b9d9 | 3 | |
ABD931 | 0:313c9277b9d9 | 4 | PwmOut servo(PB_5); |
ABD931 | 0:313c9277b9d9 | 5 | Serial pc (USBTX,USBRX); |
ABD931 | 0:313c9277b9d9 | 6 | SoftSerial blue (D2,D3); |
ABD931 | 0:313c9277b9d9 | 7 | |
ABD931 | 0:313c9277b9d9 | 8 | char receive; |
ABD931 | 0:313c9277b9d9 | 9 | int se; |
ABD931 | 0:313c9277b9d9 | 10 | //int pulso; |
ABD931 | 0:313c9277b9d9 | 11 | int main() { |
ABD931 | 0:313c9277b9d9 | 12 | |
ABD931 | 0:313c9277b9d9 | 13 | pc.printf("INICIANDOO...\n\r"); |
ABD931 | 0:313c9277b9d9 | 14 | |
ABD931 | 0:313c9277b9d9 | 15 | |
ABD931 | 0:313c9277b9d9 | 16 | |
ABD931 | 0:313c9277b9d9 | 17 | while(1) { |
ABD931 | 0:313c9277b9d9 | 18 | if (blue.readable()>0) |
ABD931 | 0:313c9277b9d9 | 19 | { |
ABD931 | 0:313c9277b9d9 | 20 | |
ABD931 | 0:313c9277b9d9 | 21 | receive=blue.getc(); |
ABD931 | 0:313c9277b9d9 | 22 | se=(receive-48)*1000; |
ABD931 | 0:313c9277b9d9 | 23 | |
ABD931 | 0:313c9277b9d9 | 24 | pc.printf("%2d " ,receive,se); |
ABD931 | 0:313c9277b9d9 | 25 | servo.period_ms(20); |
ABD931 | 0:313c9277b9d9 | 26 | servo.pulsewidth_us(se); |
ABD931 | 0:313c9277b9d9 | 27 | |
ABD931 | 0:313c9277b9d9 | 28 | } |
ABD931 | 0:313c9277b9d9 | 29 | |
ABD931 | 0:313c9277b9d9 | 30 | |
ABD931 | 0:313c9277b9d9 | 31 | |
ABD931 | 0:313c9277b9d9 | 32 | } |
ABD931 | 0:313c9277b9d9 | 33 | } |