#include "DCMDriverL298.h"
DCMDriverL298 dcMotorDriverL298(5, 2, 3, 6, 4, 7);
const int timeout = 10000;
char menuOption = 0;
long time0;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("start");
menuOption = menu();
}
void loop() {
if (menuOption == '1') {
dcMotorDriverL298.setMotorA(200, 1);
dcMotorDriverL298.setMotorB(200, 0);
delay(2000);
dcMotorDriverL298.stopMotors();
delay(2000);
}
if (millis() - time0 > timeout) menuOption = menu();
}
char menu() {
Serial.println(F("\nWhich component would you like to test?"));
Serial.println(F("(1) L298N Motor Driver with Dual Hobby DC motors"));
Serial.println(F("(menu) send anything else or press on board reset button\n"));
while (!Serial.available());
while (Serial.available()) {
char c = Serial.read();
if (isAlphaNumeric(c)) {
if (c == '1') Serial.println(F("Now Testing L298N Motor Driver with Dual Hobby DC motors"));
else {
Serial.println(F("illegal input!"));
return 0;
}
time0 = millis();
return c;
}
}
}