Help! I am trying to implement an a momentary button to the l298n and my arduino uno

I hope I put this in the right category, it is my first post but I need help on adding an momentary polarity reverse switch (https://a.co/d/5fAD0QF) to my l298n that is connected to two dc motors(12 V 15 rpm) and a 12v battery and the pins are connected to my arduino uno that has its own battery source, 9v. Any advice on how I can connect it to the l298n and the arduino uno would be amazing. I read and watch some videos but I am stuck on what to do. I thought I could connect the ground to the arduino and the positive to the l298n and somehow the motors connection to the pins?

It sounds dangerous.
What will the switch/button do in the project?

The switch should do this if we press up the two motors will go clockwise and down counterclockwise and in the middle it will stop. It is for a vertical lift bridge

With a switch like that, you don't really need an arduino. The switch can handle 12V, 10A so could be directly connected to the motors.

But, if you want to use the Uno, you would wire side of the switch to one of your Uno pins. Wire the center to ground and wire the other side to a different Uno pin.

Then, configure those to pins as INPUT_PULLUP in setup() so they will read HIGH when not pressed and LOW when pressed.

Inside of loop(), you will have to read these two pins and if one is LOW, run your motors one direction. If the other pin is LOW, run your motors the other way.

I'd suggest trying out your switch with nothing else attached and just use some Serial.print() statements to make sure you have it wired correctly before attaching the motors.

Note that the switch will not light up since that requires 12V according to the site.

Did the switch come with a wiring diagram? Can you post a photo of the diagram so we can see how the LEDs are connected?

It didn’t come with a wiring diagram but I do have this photo from Amazon.

Okay, just to make sure I understand what you are saying , you suggest to wire the ground connection to the aduino. Take the motors cables to the arduino pin? Do I connect the positive to the motor driver? The reason why we are using the motor driver and the arduino is to make sure the two motors start at the same time because we don’t want one side to tilt more than the other side for the vertical lift.

If your motors have brushes to conduct power to the armature, you will never be able to get the motors to start movement at the same time because you have no control of the armature contact segment positions. But a good learning experience.

Okay that is good to know for next time. Even if it is approximately the same time it is okay, I think it will work out okay.

Connect black one side of each motor
connect red to one side of each motor
connect ground to your power supply ground
connect +DC to your power supply

You are done. Use your Uno for something else.

Note: Make sure your motors are both turning the same direction or else you will have to switch the wiring of one of the motors.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.