Arduino Nano - How to switch output poles?

Hey. I have an Arduino Nano(old bootloader).
I'm sorry if this isn't the right topic, I really don't know where to put this :confused: .

So. I'am trying to control a mechanical clock with my Nano. The clock itself runs on 1.5V, my Arduino runs on 5V.
I'w dismembered a clock, which has a simple electromagnet (and a magnet) to turn the second's handle.

I can currently call analogWrite(pin1, 77) and hook the other end to GND to turn the handle once (with about 1.5V).
I would have to keep switching the two pins manually to keep the clock turning.
(I tried hooking both pins normally and just disabling one,(that was probably stupid) and didn't work)

Is there an easy way to change the direction of the flow of electricity on an Arduino Nano?
How? If not, what should I purchase?

Post a schematic. It is not clear how you are wiring it.

Also this whole idea of using analogWrite seems totally off base.
AnalogWrite is the PWM function.

If you want to drive a magnet use a transistor and a digital output with digitalWrite() and use a delay.

On Nano, pin 1 is NOT a PWM pin, it is the Serial TX pin, analogWriting a non PWM pin to less than 128 will set it to 0.
That "electromagnet" is the coil of a stepper motor that turns 1/4 turn with each pulse.

The pin1 is the name of the variable i was using. It is actually connected to D4 and the value of pin1 is 4.

I used the multimeter on the pin and it gave me almost exactly 1.5V. It seemed to work fine.

Digital output is putting out almost 5V. I was afraid to hook it up to the clock, even though i'm not sure if it would cause any serious damage.

I'm not sure how transistors hook up though.

I'w drawn somewhat of a schematic here. Not sure if it helps...
Its the "SEC Module"

https://drive.google.com/file/d/13HAgsAXjLvtU3Y2HNRRFp1xVyLQYe1dD/view?usp=drivesdk

You probably don't have to reverse the polarity. Can you make it "step" by connecting and disconnecting a 1.5V battery?

If necessary, an H-bridge motor driver can be used to reverse polarity (normally used to reverse a DC motor). Of course, it's just reversing the connections. It's not generating a negative voltage. So neither side of the motor/coil can be hard-wired to ground. Both terminals have to go through the H-bridge.

analogWrite() is NOT true analog. It's [u]PWM[/u]. You should be averaging 1.5V (assuming you're not drawing excessive current) and that might work with your electro-magnet or it might not. Or your electromagnet may be happy with 5V, or it may fry. (I'd be surprised if it burns-up at 5V, you've got (more than) 3 times the voltage and 3 times the current for 9 times the energy and 9 times the heat!)

Assuming this is a low-current coil, I'd recommend using a series resistor to drop the voltage. If you have a multimeter you can measure the coil resistance and then calculate a [u]voltage divider[/u]*, or you can find the correct resistor value experimentally.

The "absolute maximum" current allowable directly from an Arduino I/O pin is 40mA. That calculates-out to 125 Ohms minimum ([u]Ohm's Law[/u]). If you add a series resistor that's the sum of the resistor and coil resistance. Anything less than 125 ohms is risking damage to the Arduino so you should add a transistor or MOSFET driver, or use an H-bridge driver, etc.

You should also add a [u]flyback diode[/u] "backwards" across the coil. When you de-energize the a coil, the coil becomes a generator and without a current path you can high voltages that can damage your circuitry. The diode provides a safe current-path.

  • Normally, it's a bad idea to use a voltage divider to "power" anything, but with a fixed, low-power, load it can work and it's an easy solution.

Yes it works with the battery directly, but I have to turn the battery for each step. If I keep it on the same poles it just moves in one place.

So are you saying I should get that H-Bridge and some ressistors and wire them as you said and it will be fine? Is it ok if I don't get the flyback diode or the ressistors(I'm really bad at electronics so I would like to keep is as simple as possible) or is it absolutely necessary?

Also... this... thing was controling the entire clock. Can I make use of it?
https://drive.google.com/file/d/13JyyyY9htnvDKIxRt4ocmUKqYL8Soh7f/view?usp=drivesdk

I only want to turn the handle roughly once every 1,5 days so... if i coul power it for maybe exactly a second or something?

A stepper motor seems to work best with a stepper driver and it would only supply as much
current as the motor draws.
You can get a RAMPS A4988

Your Google picture doesn't work for me.
Please read the "how to post" sticky.

What is the resistance of that clock coil.
Maybe it's high enough to directly drive the clock from an Arduino pin, without the help of an external H-bridge.
Ofcourse using two Arduino pins for the polarity reversal, and a series resistor to limit coil current.
A "poor man's H-bridge" might also be a solution.
Leo..

Wawa:
What is the resistance of that clock coil?
Maybe it's high enough to directly drive the clock from an Arduino pin, without the help of an external H-bridge.
Of course using two Arduino pins for the polarity reversal, and a series resistor to limit coil current.

Took the words right out of my mouth, as it were!

As I understand it, these do indeed use an alternating pulse on the coil, one direction for one step, the other direction for the next step. This is vastly more efficient than requiring a spring return. So two output pins should do nicely. You may wish to put a diode bridge across the supply and outputs to suppress "kickback".

Note that it is indeed a very brief pulse, and a very low current. After all, the 1.5 V battery lasts a couple of years.

OP's schematic

Note: There is nothing in this schematic labeled "Clock Coil"

Are we to assume the box labeled "Alarm Module" is actually the stepper motor coil and if so, WHY
is there only ONE coil ?

OP says he is driving it with

Poor Man's H-Bridge

Yes, except you forgot the two resistors in the collector lines.
The resistors values can be calculated for the right coil current.
A diode bridge across coil/supply for the kickback is also needed.

Still waiting for that coil resistance.
Leo..

The diagram.

RTC
I2C data ?
Then you must use A4, A5, not D1, D2.

Alarm module ?
LED ?
ArduiMo NaMo ?
Leo..

Yes, except you forgot the two resistors in the collector lines.

Resistors added.

Vcc = 5V
VCOIL = 1.5v

RCollector (Vcc-VCOIL )\ICOIL

ICOIL = ?