[NOOB] Car signal light as digital input in arduino

Hi,

Recently, I started a project to change my car's tail lights into led strips. I'm using WS2812b as led strips and I've already managed to turn them on. Now the problem is, I can only switch them on when I'm using a push button on the breadboard.

Obviously, I can't keep pushing a button on the breadboard every time I use a signal light. So, I've decided to use LTV817 optocouplers per switch (left signal light, right signal light, brake light, tail light).
To my understanding, I can splice a wire from the 12v supply of the old halogen bulbs and connect the wires to the optocouplers then to arduino I/O input (schematic attached below). I've tested the circuit already but the leds won't turn on when switched from the optocouplers. It works just fine with push buttons.

Is there something wrong about the schematic?

The 4.7k pullup shouldbe between 5V and collector INSTEAD of between EMITTER and GND !

Voltage on collector will tgen be 5V when led is off
and 0Vwhen it is on.
It's not working because signal is floating instead of high or low when opto is offf.
Google opto circuits.

I'm confused by your schematic... Are you keeping all of those 5V switches?

If you are connecting the existing 12V switches you need one opto-isolator for every switch/input.

[u]Here is a post[/u] showing an opto-isolator schematic.

  • Vo goes to the Arduino input pin.

  • If you enable the [u]internal pull-up resistors[/u] you can eliminate R2.

  • 1K is OK for R1. Sometimes in a car the ground side is switched so you may have to wire the opto-isolator appropriately.

  • This is an inverting circuit... When current flows through LED, the opto-transistor turns on, pulling the input down so you may have to change your software logic.

As an alternative to an opto-isolator you can use an [u]over-voltage protection circuit[/u] made from a resistor and Schottky diode. I'd recommend increasing the resistor to between 1K and 10K, and if the input "floats" when the switch is off, you'll need an additional pull-up or pull down resistor (depending on how the switch is wired).

Instead of a bunch of Opto, you could feed the 30V into a cd74HC4050 powered from 5V.
5-30V input signal = 5V output signal to the Arduino.
Or a 4049 if you need an inverted signal

Don't forget 0.1uF cap on the 5V line to Gnd.

Maybe put a voltage divider on each input if you''re really seeing 30V as voltage spikes.
Or a surge suppressor, Varistor, MOV, etc.

Have you checked that the vehicle lighting regulations will allow you to do this? Wouldnt want you to go to all that trouble and expense and have to take it all off again!

Okay so I swapped the 4.7k resistor and Vo from the emitter pin to the collector pin. The led turned on but it wont switch off. I didn't even supply 12v to the optocoupler yet.

I'm desperate now. Is there other alternatives to get a 12v signal from the car to the arduino?

Here's how it looks like from the breadboard

Post a drawing of that.