H BRIDGE PARA MOTORES DC KL64Z
Dependencies: Motor mbed Servo
main.cpp
- Committer:
- mderrant
- Date:
- 2014-07-30
- Revision:
- 3:858e483420a8
- Parent:
- 2:d10dff926d9a
File content as of revision 3:858e483420a8:
#include "mbed.h" #include "Motor.h" #include "Servo.h" Servo s1(PTA13); Motor motor1(PTA1, PTA2, PTD3); // pwm, fwd, rev Motor motor2(PTA12,PTA4,PTA5); AnalogIn sensorizq(PTB0); AnalogIn sensorder(PTB2); PwmOut anout(LED_RED),anout2(LED_GREEN); float valorizq,valorder; 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; motor1.speed(valorizq/10); motor2.speed(valorder/10); s1 = sensorizq.read(); anout = valorizq/200; anout2 = valorder/200; // wait(3.0); // printf("%u \r",sensorizq.read_u16()); } }