# Arduino nano up to 5V input on one single Pin to control Stepper

Hi guys!

I´ve got a problem.
I need a script for the Arduino Nano that takes a up to 5V positive or negative signal of one single wire and converts it into the Dir and Step-Signal in order to control a Nema 17 stepper using a a4988 driver.
Dir is on Pin 2 and Step on pin 3 and VDD and Ground are already used by the driver.
The script should take the one-wire signal, if this is positive, the stepper should turn clockwise, if it's negative the Stepper should turn the opposite direction. The Voltage of the Signal (-5V until 5V) say which speed it should take, 0V means on turn, 5V means Full clockwise, -5V means opposite full. -2.5 half speed and so on.
It would be great if you could help me out with a script.

kind regards,

Klaus Deike

(deleted)

Okay, if I understood you properly I can only give 0-5,5 V to the digital pins.
Is there any possibility to give negative signals into is?

(deleted)

Okay, but I don't find anything with only one cable on the internet.
could you write some code for that because I can't.

Or could anyone else help?

(deleted)

Divide your +/-5V signal in half using two 100K resistors, then run it thru a 1uF cap to two more 100K resistors into an analog pin. The cap removes the DC component of the input signal, the 2nd set of resistors offset that to 2.5V for the analogRead.

Experiment with R values and the Cap value to see what works well for you before connecting to an analog pin.

analogRead value of 512 = middle position
0 = full one direction
1023 = full the other direction.

You may have to use something like <=5 for full one side,
and >=1018 for full the other.