L298N 4 channel MOTOR DRIVER

Hi everyone.

I want to control 4 solenoid valve (24vDC) with a L298N 4 channel MOTOR DRIVER.
Can anyone help me in wiring and its related code?
i have done it similar to a 2 channel one, but it does not work (it does not supply 24v to its outputs).


Please post the code and schematic that you have tried

int valvepin1 = 2;
int valvepin2 = 3;

void setup() {

pinMode(valvepin1, OUTPUT);
pinMode(valvepin2, OUTPUT);

void loop() {

digitalWrite(valvepin1, HIGH);
digitalWrite(valvepin2, LOW);


Is that really - and + 24V going in ?
What voltage, if any, do you get out ?
Why are the inputs labelled PWM 3 and PWM 2 when you are using digital pins ?
Are the ENA and ENB inputs enable pins as their name suggests and if so are they active HIGH or LOW ?

1- yes. it is exactly 24v. i have a power supply.
2- 24v. it does not supply to out 7 and 8.
3- sorry. i write wrong. they are digital pins.
4- ENA , ENB are enable pins. they are high by default with jumper. and i dont write in code

My query was that the diagram was labelled plus and minus 24V

So where are you seeing the 24V out ?

1- oh. excuse me. the arrows of + - 24 vDC is reverse. i am sorry.
2- i dont see 24 volt any where. i want to see it between out 7 and 8 but it shows 0.

Hi, @rashad_rhl
Welcome to the forum.
Why do you want to control valve solenoids with a motor controller.
Do you need to apply current in one direction to open and the other to close?

If not then just a MOSFET for each valve could have done the job instead of a module that is not very efficient.

Thanks… Tom… :grinning: :+1: :coffee: :australia:

Hi TomGeorge
Thanks for your reply
of course you are write. but i have this module. and i am going to use it.
can you help me?

Do you have a link to data/specs for the module?

Thanks… Tom… :grinning: :+1: :coffee: :australia:

I know that it is being picky, but I presume that you do not have plus and minus 24V but have GND and plus 24V

no. unfortunately this module is not common

I think minus and GND are the same. isnt it?
i have connect GND too. but does not work

This is it,

What is your 24V supply?
Can you post a circuit diagram?
What are the specs on your valve solenoids?

Thanks… Tom… :grinning: :+1: :coffee: :australia:


plus and minus must always be in relation to something, you can’t have a plus voltage unless you have something to measure it against. So, when you have plus 24V and minus 24V the difference between them could actually be 48V

I never thought for minute that is what your labels meant but there were other obvious things wrong so this could have been too, hence me asking

1- i have a power supply that supply 24v Dc
2- my valve is a 24v DC solenoid valve (gevax valve)

Do you have a DMM?
Can you power supply operate 4 of your valves?

Tom… :grinning: :+1: :coffee: :australia:

you are write. my supply is 24v (plus and GND)

i dont know what DMM is.
2- yes it can


A Digital MultiMeter.
Do your valves have part numbers?
What Arduino controller do you have?

Tom… :grinning: :+1: :coffee: :australia: