I am controlling a 12V DC motor forwards and backwards using the DC Motor Featherwing from Adafruit. I have the motor rotating a drive shaft which moves a slide horizontally. I purchased some limit switches so that when the slide hits the limit on either side, I would like for the motor to stop in that direction and send a control signal to the Arduino.
I want the motor to be stopped by hardware without the uC controlling it, but I do want the uC to get notified. Turning the motor in the other direction is the only way to move the motor. In code, I would just poll the A1 and A2 for a HIGH control signal.
I put together a schematic (attached) that I think may work. Does anyone see any issues with it? I’m new to motors, and I wasn’t sure if current would still flow through to the Arduino from the 12V battery with this schematic.
You should NOT send 12v to an Arduino input. Negative 12V even more so!
I think the limit switches will stop the motor. You may be able to make the voltage safe for the Arduino input with a diode (to prevent negative voltages) and a voltage divider to reduce the voltage to between 4.5 and 5V.
Applying 12V to any pin on an Arduino would fry it instantly. Try this circuit: It uses MOSFETs to switch the Analog pins. When the a motor pin is high, the Arduino will read 0V. When a motor pin is low, the Arduino will read 3V. Any transistor would work instead of a MOSFET. Just make sure the gate voltage is fine up to the motor voltage (12V).
Is the motor to reverse direction under program control only or will there be manual intervention?
The motor will be reversed under program control using the DC Motor Featherwing. The code will still need to cut the motor off when limits are hit, but I was concerned about software hangs. I wanted to make sure the motor was turned off regardless of software (via the supply to the limit switch), but also get notified to turn off the motor at the Featherwing. Maybe it’s over-engineered?
So, I think I’m going to stick with using the uC to switch off the motor via the featherwing when the limit switch is open. The 12V supply will only be connected between the featherwing and battery. I just don’t quite have the knowledge nor expertise for hardware controlled.
How can reversing direction now run the motor?
I thought using a diode between the C and NC pins on both switches (but opposite direction) from the 12V supply would handle that. It should allow current to still flow through the other switch when one is broken. I just wanted the switch to send a signal to the Arduino when open (see my first schematic).