David's line following code from the LVBots competition, 2015.
Dependencies: GeneralDebouncer Pacer PololuEncoder mbed
Fork of DeadReckoning by
motors.cpp
- Committer:
- DavidEGrayson
- Date:
- 2014-02-20
- Revision:
- 6:89a39870e23d
- Parent:
- 5:01ad080dc4fa
- Child:
- 7:85b8b5acfb22
File content as of revision 6:89a39870e23d:
#include <mbed.h> static PwmOut motor1Pwm(p26); DigitalOut motor1Dir(p25); static PwmOut motor2Pwm(p24); DigitalOut motor2Dir(p23); void motors_init() { motor1Pwm.period_us(50); motor2Pwm.period_us(50); motor1Pwm.pulsewidth_us(20); motor2Pwm.pulsewidth_us(20); LPC_PWM1->MR0 = 1200; // Set the period LPC_PWM1->MCR = (1 << 1); // Reset PWMTC when it is equal to MR0. } void motors_speed_set(int16_t motor1_speed, int16_t motor2_speed) { LPC_PWM1->MR1 = motor1_speed; LPC_PWM1->MR3 = motor2_speed; }