Arduino Help!

Hello,

I am making a daytime running lights controller using an arduino.

I have attached the wiring diagram of what I am using.

Basically I need to use the positive feed from the LED to tell the Arduino through the optocoupler whether the LED is on or off.

I am sure it is simple but I just can’t work it out!

Please, can you post your source and your scheme?

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(digitalRead(13));
}

Thats my code. The schematic is attached. I just need to know how to get a high or low in the arduino when the led is on or off.

Wiring diagram looks right to me - is that the right value of resistor in series with the led in the opto? That looks a bit high it's probably getting like 2mA.

And, the +12 and Ground on the 12v side of the opto need to be connected in parrallel with the LED (ie, closer to the LED than whatever mechanism is used to switch the LED).

Why do you not know the status of the LED, if you're making something to control it? How can the controller not know if the LED is on?

DrAzzy:
Wiring diagram looks right to me - is that the right value of resistor in series with the led in the opto? That looks a bit high it's probably getting like 2mA.

And, the +12 and Ground on the 12v side of the opto need to be connected in parrallel with the LED (ie, closer to the LED than whatever mechanism is used to switch the LED).

Why do you not know the status of the LED, if you're making something to control it? How can the controller not know if the LED is on?

Sorry I was a bit unclear.

The LED is the car sidelight so I need to get when that is off or on preferably just from the positive feed! The arduino is being powered by a 12V feed from the battery.

Since digital pin 13 is attached to the onboard led, I would suggest using another digital pin. How about pin 11.

So if you connect your optocoupler to dio11, and change your code to.

"void loop() {
  Serial.println(digitalRead(11));
}"

You should get 1 or 0 printed, depending on whether there is voltage sent to the led.