Hello,
I posted a topic in the project guidance forum found here https://forum.arduino.cc/index.php?topic=706271.msg4745954#msg4745954 which was for a dispenser system that uses pololu's
150:1 Metal Gearmotor 37Dx57L mm 12V (Helical Pinion) with the VNH5019 Motor Driver Carrier. I am using a Teensy 3.2 to run my system and it seems that I have some sort of delay or latency and I imagine that my issue could be in my code here:
unsigned long startTime = millis();
while (millis() - startTime < dispensingTimout) {
dp.showSaleScreen(fin_weight);
// Toggle motor depending on whether
// button is pressed
if (dp.isButtonPressed()) {
startTime = millis();
// Serial.println("Dispensing.");
dp.motorOn(255);
} else {
dp.motorOff();
}
}
Where the dispensingTimout is a const int = 5000ms. When the button is pressed, I need to hold it down for the driver to register a signal and spin my motor. If I hold it, even momentarily, it will spin my motor with a delay before it turns my motor off and thus over-dispensing. Is my issue with the while loop here??
Note: Since my code is very long and is composed of three classes, I have attached a zip file of my entire code below.
Thank you!
firmware_slave.zip (7.01 KB)