reversing polarity on a car door actuator

Hi Guys, I am new to the forum, electronics and Arduino. I have been doing some basic stuff with LED blinks sketches and the like and have managed to write a sketch that senses temperature and switches a green LED on if in the range and a red LED if over the range. - just some background on my skill levels

My ultimate goal is to have my arduino sense temperature increases and automatically start my petrol powered bushfire pump.

I have been trying to use a central door lock actuator to move the choke and the throttle on the engine, but I am having trouble switching the polarity.

I have two options and am having difficulty with both

  1. using a 8 channel relay https://www.jaycar.com.au/arduino-compatible-8-channel-relay-board/p/XC4418
  2. using a H Bridge L298N

I can get the actuator to switch in one direction with the relay set but not switch polarity and run in the other direction. I am not sure if it is a coding issue or a wiring issue.

with the H bridge it appears to kind of work but only slowly and there is a lot of buzzing.

Just wondering what is the best way to go. any clues would would be appreciated

void setup() {
  // H Bridge setup:
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
analogWrite(9, 254);
delay(2000);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
analogWrite(9, 254);
delay(2000);

}

//Relay setup

int RELAY1 = 9;
int RELAY2 = 7;   
void setup()
{   
// Initialise the Arduino data pins for OUTPUT
pinMode(RELAY1, OUTPUT); 
pinMode(RELAY2, OUTPUT);

}
void loop()
{
digitalWrite(RELAY1,LOW);  // Turns ON Relays 1

delay(2000);  // Wait 2 seconds  

digitalWrite(RELAY1,HIGH); // Turns Relay Off
//delay (2000);
//digitalWrite (RELAY1, LOW);


digitalWrite(RELAY2,LOW);  
// Turns ON Relays 2
delay(2000);    
// Wait 2 seconds
digitalWrite(RELAY2,HIGH); 
// Turns Relay Off

There's going to be some noise due to the PWM signal driving the motor. What are you using for a power supply? It has to have enough oomph to drive the motor. The el cheapo ones I got from Amazon pull 4 amps stalled.

It is permissible to (and I did) parallel the 298 outputs for more power capability.

I am not sure if it is a coding issue or a wiring issue.

Posting a schematic would allow someone to offer an opinion on that. Hand drawn is OK.

If you want to use relays, consider a "reversing relay" topology:

A couple of DPDT relays will give you the reversing while a third SPST relay can be used as a "master" to switch current to the motor from the source.

For the H-bridge, what are you using for a motor supply to the bridge?

Use a couple of r/c servos.

Blackfin:
If you want to use relays, consider a "reversing relay" topology:

A couple of DPDT relays will give you the reversing while a third SPST relay can be used as a "master" to switch current to the motor from the source.

Waste of relays and clumsy though. Much more appropriate to use two SPDT relays - which are the more common and durable - one switches each end of the motor between ground (default) and supply.

Note however that this circuit on its own does result in dynamic braking. If that is undesired (or needs to be optional), add two diodes.

Paul__B:
Waste of relays and clumsy though. Much more appropriate to use two SPDT relays - which are the more common and durable - one switches each end of the motor between ground (default) and supply.

Note however that this circuit on its own does result in dynamic braking. If that is undesired (or needs to be optional), add two diodes.

Paul_B Thank you so much for the wiring diagram on the SPDT relays. I have wired this up and written the code and it works perfectly