Limit switch preventing Arduino 5V signal

Hello,

I want to run a motor that will be fully opening or closing a small enclosure using push-button switches.

Attached is a brief circuit using one push-button which when pushed will send a HIGH signal to Ardunio and then Arduino will send HIGH to pin 4 and LOW to pin 7 which are respectively connected to pins 6 and 3 of the L293D h-bridge.
This will run the motor in clockwise direction.

My idea is to add a limit switch that stops the motor.
The problem is I want the limit switch to be directly connected to the voltage sent to the motor so when pushed, pin 6 of the h-bridge will no longer receive 5V whatever happens. (since this is connected to ground).

However, this will fry the Arduino since pin 4 (that sends HIGH) will be connected to ground when limit switch is pushed.

Is there an alternative way to connect the limit switch so it prevents the motor from receiving voltage even when pin 4 sends high?
I don’t want to connect the limit switch to the logic of Arduino since the signal received by the limit switch might not work and this will lead to disaster

Thank you!

The output of the Arduino is a HIGH logic level without much current. By putting a series R of a couple of Kohms between the out of the Arduino and input of the driver, you can safely use your switch to short out the driver input.

Weedpharma

weedpharma:
The output of the Arduino is a HIGH logic level without much current. By putting a series R of a couple of Kohms between the out of the Arduino and input of the driver, you can safely use your switch to short out the driver input.

Weedpharma

Thank you :slight_smile:
Should I be using a resistor between the switch and ground too or not necessarily?

No, the switch can just short to ground when pressed. The resistor protects the Arduino pin from too much current.

Will try it tomorrow, thanks for the help

Hi,

I don't want to connect the limit switch to the logic of Arduino since the signal received by the limit switch might not work and this will lead to disaster

If the signal FROM the limit switch might not work, how will it work if you directly connect it to the driver IC?

For safety and using standard practice, limit switches are usually ON and the gate hitting them will turn them OFF.

By the way how will you reverse the driver chip if you have incapacitated on of its inputs?

Tom... :slight_smile:

TomGeorge:
By the way how will you reverse the driver chip if you have incapacitated on of its inputs?
Tom... :slight_smile:

He's connecting the switch to the L293D pin that will be high when the motor is turning in the original direction, which will pull that pin low. When the motor has to turn in the other direction, the pin not attached to the switch goes high, and the one attached to the switch will be made low. ie He's not putting the switch on the enable pin.
It makes sense, even if my description doesn't. :smiley: