Intermittent wiper control with auto park

Hey guys and gals, I am a bit of a newbie with arduino coding, I am trying to build an adruino circuit to control the wiper motor on my snow removal John Deere tractor. What I currently have is a regular wiper motor with a ON/OFF switch, the wiper motor doesn't have an auto park sensor/switch.

I know about electronics, so no problems there...

I have a couple Arduino Nano V3.0 (clone) and a few "IR Infrared Obstacle Avoidance Sensor Module for Arduino" (‎EK1254x5C). I would like to use the IR Infrared Obstacle Avoidance Sensor for the wiper parking by applying a reflective tape on the wiper arm and installing the IR sensor inside the Tractor Cab (I used a shrink tubing to insulate sunlight from triggering the IR sensor and this is working great).

I have found this Arduino code for the wiper intermittent control portion here:

    int sensorPin = A1; // Delay Potentiometer
    int motorPin = 2; // Wiper Relay
    int interval = 0;
    int IR1 = 10; // Added the Infrared Obstacle Avoidance Sensor for wiper parking

    void setup() {
    // declare the ledPin as an OUTPUT:
    pinMode(motorPin, OUTPUT);
    pinMode(LED_BUILTIN, OUTPUT);
    pinMode(IR1,INPUT); // Added the Infrared Obstacle Avoidance Sensor for wiper parking
    Serial.begin(9600);
    }

    void loop() {
    
    int sensorValue = analogRead(A1);
    if (sensorValue <= 10) {
    interval = 0;
    }
    else interval = (2000 + (sensorValue * 8));
    

    Serial.println(interval);
    Serial.println(sensorValue);

    digitalWrite(motorPin,HIGH);
    digitalWrite(LED_BUILTIN, HIGH);

    delay (1000);

    digitalWrite(motorPin,LOW);
    digitalWrite(LED_BUILTIN, LOW);

    delay (interval);

    }

I have tested this code on Tinkercad circuit and the code does work for the wiper intermittent control, however I would like to implement the wiper parking to this code in a way that the wiper does a complete sweep (Back and forth) then the timer set by the potentiometer is activated for each consequent sweeps.

The above code will provide non-stop wiper motion when the potentiometer is set to the minimum, then intermittent delay increase as potentiometer is turned clockwise.

So, basically, what I need is this:

  • When Wiper Power Switch is turn ON, and potentiometer is set to minimum, wiper motor is working continually.
  • If potentiometer is turned clockwise, this will activate intermittent wiper sweep and wiper will park itself between each sweeps via the IR Infrared Obstacle Avoidance Sensor.

Can anyone help me with this?

Cheers
Dan

You might be better off with a limit switch operating on the mechanism away from the weather for the park function .
If you look at the motor , there may be another version available with auto park built in .
You might want to look at braking the motor ( by shorting it’s power connections ) to make it stop quickly

Thanks for your reply, there are several ways to detect wiper arm position, I can also use a Hall Effect sensor and stick a magnet to the wiper arm, or a limit switch or IR sensor with reflective tape... all the sensors will do is to set a digital pin at 0 on the Arduino board.

However, what I really need is the coding section to achieve intermittent wiper control from the park position detected from whatever I wish to use, so basically when a digital 0 is detected at a digital pin on the arduino, the sequences start...

I guess your right about braking the motor for quick stop, I can achieved this with a double pole relay or by using a MOSFET ...

Can you help with this code?

Give the motor pin a pulse just long enough to drive the motor off the stop switch, motor will stop when it comes back around to the switch. Code could be simple as:
digitalWrite(motorPin, digitalRead(stopSw) || pulse);

I think I got it to work, here is the code for it:


    int sensorPin = A1; // Delay Potentiometer
    int motorPin = 2; // To Wiper Relay
    int interval = 0;
	int IR1 = 10; //Infrared Obstacle Avoidance Sensor for wiper parking

    void setup() {
    // declare the ledPin as an OUTPUT:
    pinMode(motorPin, OUTPUT);
    pinMode(LED_BUILTIN, OUTPUT);
    pinMode(IR1,INPUT);
    Serial.begin(19200);
    }

    void loop() {
    
      
    int sensorValue = analogRead(A1);
    if (sensorValue <= 10) {
   	interval = 0;
    }
    else interval = (2000 + (sensorValue * 8));
         
    Serial.println(interval);
    Serial.println(sensorValue);

    digitalWrite(motorPin,HIGH);
    digitalWrite(LED_BUILTIN, HIGH);
    delay (1000); // Pulse the motor to move wiper arm to deactivate the IR sensor
        
    if(digitalRead(IR1)==LOW)
      
    {
    digitalWrite(motorPin,LOW);
    digitalWrite(LED_BUILTIN, LOW);
    delay (interval);
    }  
    else if(digitalRead(IR1)==HIGH);
 
    Serial.println(interval);
    Serial.println(sensorValue);

    digitalWrite(motorPin, HIGH);
    digitalWrite(LED_BUILTIN, HIGH);
    
    }

   

When testing under Tinkercad Circuit, it looks like it will work.
When potentiometer is set to minimum and powering the circuit, the wiper motor run continually.
If I turn the potentiometer clockwise, then it will run until the IR sensor/switch is triggered "0", then the set timer will run and pulse the motor so to move the wiper arm pass the IR Sensor and will do a complete sweep until the IR sensor is triggered again, then the cycle begin again...

Will have to try it in real world and will have to add a circuit to make the motor stop immediately when instructed to by using a MOSFET or relay to short out the motor coil.

Do you think this will work?

Cheers