Hello people, I need help to improve a project that consists of controlling an Auto-Return Wiper Motor for my tractor that adds variable intermittent motor control via a Slide Potentiometer. I am using a small Arduino Nano V3.0 for this.
Basically, how it works is when the Slide Potentiometer is all the way to the left, the wiper motor is working in continuous mode, the further you move the slide Potentiometer to the right, the longer the Intermittent Delay is (set at 10 Seconds Max) .
The problem I have now is when the slide potentiometer is set for longer intermittent delay and I need to activate the wiper motor immediately in continuous mode (ex. blowing snow hitting the windshield fast after going in a corner of a building), it will not engage immediately after I slide the potentiometer all the way to the left, it will wait for the full-time delay to pass before going in continuous mode.
Is there something I can add to my code so that continuous mode is activated as soon as the slide potentiometer is moved to the far left?
You can see it on wokwi.com here:
https://wokwi.com/projects/360461321219183617
and here is my current code
// This simulation is to add intermittent control to an Auto Return wiper motor for a tractor.
// When the Slide Potentiometer is all the way to the left, wiper motor is in continuous mode.
// The further you move the slide Potentiometer to the right, the longer the Intermittent Delay is (10 Seconds Max)
// The blue LED is to simulate when the Auto Return Wiper Motor would be powered by a 12 V source
int sensorPin = A1; // Delay Slider Potentiometer
int motorPin = 2; // To Wiper Relay
int interval = 0;
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(motorPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A1);
if (sensorValue <= 1) { // Determine the minimum potentiometer position before intermittent wipers is activated
interval = 0; }
else interval = (1 + (sensorValue * 9)); // Determine the maximum intermittent seconds
//Serial.println(interval);
//Serial.println(sensorValue);
digitalWrite(motorPin,LOW);
digitalWrite(LED_BUILTIN, HIGH);
delay (200); // Pulse the motor to move wiper arm to deactivate the Hall Effect Sensor
digitalWrite(motorPin, HIGH);
digitalWrite(LED_BUILTIN, LOW);
delay (interval);
}
Any help would be appreciated
Cheers,