Reversing Polarity without using a switch

Hi guys,

I am relatively new to programming with an arduino.

I am currently trying to control and electronic lock using the arduino board. The lock requires 5v to work and consists of a motor inside which basically performs the lock and unlock function.

I have used a TIP120 transistor and a 1k resistor and diode for protection.

I am using the following schematic just substituted the motor with the lock: Controlling A Solenoid Valve With Arduino - BC Robotics.

However, I am only able to perform the lock function in order to unlock it I have to switch the polarity of the lock.

Is there a way to do this without using a switch.

I want the door to be locked when the user input digit 1 and unlocked (i.e. the polarity reversed) when the user input digit 2.

I need this all to be automated without any manual switching.

Thanks.

You could use an H-bridge motor driver to reverse the current to the motor. Pololu is one source of H-bridge drivers.

The site you show says that the valve is normally closed at rest and then opens when you apply voltage. Are you sure you even need to reverse the polarity? Have you tried manually doing it (just a voltage source and wires, no transistor or Arduino) to see if the effect is what you want?

If it is, one way to reverse voltage is to use an H-bridge as someone pointed out. You could also borrow a circuit idea from the automotive world for power windows using two relays.

Basically, the valve will have ground on both leads when nothing is going on. But switch one of the two relays and a positive voltage will replace one of the grounds. Same goes for the other relay when switched separately. Thing is, you will need to place a transistor on each relay's coil switching the ground to control from an Arduino.