#include "DCMotor.h"
#include "Devices.h"
#include <Arduino.h>
const int MOTOR_IN1 = 10;
const int MOTOR_IN2 = 11;
const int REVERSE_BUTTON = 2;
const int REVERSE_LED = 4;
const int THROTTLE_POT = A0;
DCMotor motor(MOTOR_IN1, MOTOR_IN2);
Switch reverseSwitch(toggleReverse);
void toggleReverse() {
motor.toggleReverse();
}
void setup() {
pinMode(REVERSE_LED, OUTPUT);
pinMode(REVERSE_BUTTON, INPUT_PULLUP);
}
void loop() {
float throttle = map(analogRead(THROTTLE_POT), 0, 1023, 0, 100) / 100.0f;
reverseSwitch.debounce(!digitalRead(REVERSE_BUTTON));
digitalWrite(REVERSE_LED, motor.isReverse());
motor.drive(throttle);
}