diff --git a/lawndon/drive.h b/lawndon/drive.h index 05cade5..7c69820 100644 --- a/lawndon/drive.h +++ b/lawndon/drive.h @@ -10,11 +10,11 @@ extern Servo leftEsc; extern Servo rightEsc; // pin defs -#define ESC_LEFT_PWM 4 #define ESC_LEFT_POWER 3 +#define ESC_LEFT_PWM 4 -#define ESC_RIGHT_PWM 11 #define ESC_RIGHT_POWER 10 +#define ESC_RIGHT_PWM 11 // Throttle positions #define ESC_MIN_THROTTLE 1000 diff --git a/lawndon/motor.cpp b/lawndon/motor.cpp index 7fc937d..5dad1e9 100644 --- a/lawndon/motor.cpp +++ b/lawndon/motor.cpp @@ -12,6 +12,9 @@ Motor::Motor() {} void Motor::setup() { Console.println(F("Initializing motor config")); + // Setup for changing the PWM frequency of pin 7 + setupTimer4(); + // Attach Mower ESC Console.println(F("Attaching mower ESC")); mowerEsc.attach(ESC_MOWER_PWM, 1000, 2000); @@ -35,3 +38,7 @@ void Motor::loop() { mowerEsc.writeMicroseconds(1000); } } + +void Motor::setupTimer4() { + TCCR4B = TCCR4B & 0b11111000 | 0x04; // Set prescaler to 256 for Timer 4 +} \ No newline at end of file diff --git a/lawndon/motor.h b/lawndon/motor.h index 1df0e2d..ea89145 100644 --- a/lawndon/motor.h +++ b/lawndon/motor.h @@ -14,6 +14,8 @@ class Motor { virtual void setup(); virtual void loop(); + + virtual void setupTimer4(); }; extern Motor motor;