Programming for Single Wire with Switching Polarity

Hello, I have been recommended to use an Arduino to program some functions on a motorcycle. No experience with this but keen to learn. First I thought I should find out the feasibility before diving in.

I have a 3 wires as separate inputs and then 4 outputs. Two inputs are simple momentary buttons: a toggle on / off (headlight) and a cancel (indicator).
The headache and my primary concern are the indicator directions, which are a single wire input. A positive pulse for left, negative for right (wired as below), to then become a separate L/R output. This is not changeable unfortunately.

I have been looking into some complex circuitry solutions to solve this but proving difficult and unreliable. Is this something an Arduino could be programmed to deal with more easily and reliably in a 12V system? Thank you for any advice offered and I hope I have been clear.

6wrtY2f.png

6wrtY2f.png

Easy with two optocouplers and a resistor. Full isolation. Signal1 and signal2 go to two Arduino pins.
Mind: set the pins to INPUT_PULLUP, they’re active low.
schematic.png

Here's an idea that may be simpler than the above, but I need other forum members to check first.

The idea is to read the digital input first in INPUT mode, then in INPUT_PULLUP mode.

If the indicator switch is connected to ground, both readings will be LOW.

If the indicator switch is connected to 12V, then both readings will be HIGH.

If the indicator switch is floating, then INPUT mode should read LOW but INPUT_PULLUP mode should read HIGH (internal pull-up resistor ~30K easilly defeats the 750K).

Concern: the high value resistors will make the Arduino input susceptible to noise, which will be high because it's a motorbike.

EDIT: No, it won't work... When the indicator switch is connected to ground, the internal pull-up resistor will still defeat the external resistors.

Ok, maybe with an analog input...

PaulRB:
Ok, maybe with an analog input...

Looks like that should work indeed.

The high resistor values will give problems with noise (and are way higher than the recommended 10k impedance for the analog inputs), you can reduce them by a factor of 100 or so. So 10k and 7k5.

wvmarle:
you can reduce them by a factor of 100 or so. So 10k and 7k5.

Agreed, was left with higher values from my earlier attempt to use digital input. But need to ensure the left hand pair are correct to bring 12V down to 5V.

Also, spotted an error in your schematic in post #2. Pins 1 & 2 are reversed on the left hand optocoupler (anode is connected to ground).

Good teamwork!

wvmarle:
Easy with two optocouplers and a resistor. Full isolation. Signal1 and signal2 go to two Arduino pins.
Mind: set the pins to INPUT_PULLUP, they’re active low.
schematic.png

What on earth is that circuit supposed to do?

Hint: Voltage divider containing two 4k7 resistors between 12 V and ground. Two opto-couplers with LEDs back-to-back, connected between midpoint of voltage divider and the switches.

Better make sure both switches never get closed simultaneously. :astonished:

Alternative: Two optocouplers, each with a 4k7 resistor, as a voltage divider across the 12 V. Then the switches connect to the midpoint.

Paul__B:
Better make sure both switches never get closed simultaneously. :astonished:

Paul, I think the schematic posted by wmvarle is an honest attempt to represent, in Eagle, the diagram of the turn signal switch posted in the OP. The diagram in the OP appears to show a switch that physically can't short 12V to ground. So I think we should interpret wmvarle's schematic as though the two switches can't be closed simultaneously.

Indeed those switches are a representation of the one OP sketched - somehow interconnected so they can not be closed at the same time. I tried to make it look as much as possible like their image.

Of course only one of them may be closed at the same time (or none).

SW1 and SW2 appear to be a single physical unit in OP's motorbike. So connecting two resistors between them is not possible. With two separate switches indeed that'd be the appropriate way of doing it.

It's done in KiCAD, by the way. Not Eagle. And indeed pins 1 and 2 of U1 are connected the wrong way around.

PaulRB:
So I think we should interpret wmvarle's schematic as though the two switches can't be closed simultaneously.

I wasn't really concerned about that, but of the obvious adverse consequences of his optocoupler wiring proposal.

wvmarle:
So connecting two resistors between them is not possible.

Can't say I ever suggested any such thing. Just two alternative actual ways of doing it with opto-couplers.