H BRIDGE PARA MOTORES DC KL64Z
Dependencies: Motor mbed Servo
main.cpp
- Committer:
- mderrant
- Date:
- 2014-07-28
- Revision:
- 2:d10dff926d9a
- Parent:
- 1:6ee374b19aaf
- Child:
- 3:858e483420a8
File content as of revision 2:d10dff926d9a:
#include "mbed.h" #include "Motor.h" Motor motor1(PTA1, PTA2, PTD3); // pwm, fwd, rev Motor motor2(PTA12,PTA4,PTA5); AnalogIn sensorizq(PTB0); AnalogIn sensorder(PTB2); AnalogIn sensorcentro(PTB1); PwmOut anout(LED_RED),anout2(LED_GREEN); float valorizq,valorder,valorcentro; int main() { while(1) { /* for (float s= -1.0; s < 1.0 ; s += 0.01) { motor1.speed(s); motor2.speed(s); wait(0.02); } for (float s= 1.0; s >-1.0 ; s = s-0.01) { motor1.speed(s); motor2.speed(s); wait(0.02); } */ valorder = 1.0-sensorder; valorizq = 1.0-sensorizq; valorcentro = 1.0-sensorcentro; motor1.speed(valorizq/10); motor2.speed(valorder/10); anout = valorizq/200; anout2 = valorder/200; // wait(3.0); // printf("%u \r",sensorizq.read_u16()); } }