Dependencies: mbed
main.cpp@0:4e7abff23e4d, 2019-09-14 (annotated)
- Committer:
- NeoLewis
- Date:
- Sat Sep 14 11:10:55 2019 +0000
- Revision:
- 0:4e7abff23e4d
13/09
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NeoLewis | 0:4e7abff23e4d | 1 | #include "mbed.h" |
NeoLewis | 0:4e7abff23e4d | 2 | //#include "Motor.h" |
NeoLewis | 0:4e7abff23e4d | 3 | |
NeoLewis | 0:4e7abff23e4d | 4 | #define MAX_PPM 2006 // Valor indicando que o motor deve ir para frente com 100% de acordo com o ppm |
NeoLewis | 0:4e7abff23e4d | 5 | #define MED_PPM 1505 // Valor indicando que o motor deve ficar parado de acordo com o ppm |
NeoLewis | 0:4e7abff23e4d | 6 | #define MIN_PPM 1003 // Valor indicando que o motor deve ir para tras com 100% de acordo com o ppm |
NeoLewis | 0:4e7abff23e4d | 7 | |
NeoLewis | 0:4e7abff23e4d | 8 | PwmOut LeftMotor(p25); //Definicao da porta do motor da esquerda |
NeoLewis | 0:4e7abff23e4d | 9 | PwmOut RightMotor(p26); //Definicao da porta do motor da direita |
NeoLewis | 0:4e7abff23e4d | 10 | |
NeoLewis | 0:4e7abff23e4d | 11 | int main (void) |
NeoLewis | 0:4e7abff23e4d | 12 | { |
NeoLewis | 0:4e7abff23e4d | 13 | |
NeoLewis | 0:4e7abff23e4d | 14 | RightMotor.period_ms(16); |
NeoLewis | 0:4e7abff23e4d | 15 | RightMotor.pulsewidth_us(MED_PPM); |
NeoLewis | 0:4e7abff23e4d | 16 | |
NeoLewis | 0:4e7abff23e4d | 17 | LeftMotor.period_ms(16); |
NeoLewis | 0:4e7abff23e4d | 18 | LeftMotor.pulsewidth_us(MED_PPM); |
NeoLewis | 0:4e7abff23e4d | 19 | wait(5); |
NeoLewis | 0:4e7abff23e4d | 20 | |
NeoLewis | 0:4e7abff23e4d | 21 | while(1) |
NeoLewis | 0:4e7abff23e4d | 22 | { |
NeoLewis | 0:4e7abff23e4d | 23 | wait(4900); |
NeoLewis | 0:4e7abff23e4d | 24 | LeftMotor.pulsewidth_us(MAX_PPM); wait(0.01); |
NeoLewis | 0:4e7abff23e4d | 25 | RightMotor.pulsewidth_us(MAX_PPM); wait(0.01); |
NeoLewis | 0:4e7abff23e4d | 26 | } |
NeoLewis | 0:4e7abff23e4d | 27 | |
NeoLewis | 0:4e7abff23e4d | 28 | return 0; |
NeoLewis | 0:4e7abff23e4d | 29 | |
NeoLewis | 0:4e7abff23e4d | 30 | } |