Hello,
as tittle says..I want to get signal from a 12V lamp to check whether is on or off.
How can I do this?
Thanks
Hello,
as tittle says..I want to get signal from a 12V lamp to check whether is on or off.
How can I do this?
Thanks
Connect the 12V to a potential divider and feed the junction into a digital input.
Note the 12V has to be DC for this to work.
If you want to check whether the lamp still functions, use a potential divider made of a standard resistor plus LDR.
You can connect it to 5v and read it using analogread.
potential divider wont hurt the lamps battery?
its for a motorcycle..
Do you want to check if the light is burning? Or do you want to know it's switched on? (Two different tings
) For the last, just use a voltage divider to connect it to an IO pin. And no, it wont hurt the lamp or the battery if you pick resistors in the range of 100k. Compared to the 50W of the bulb it's just nothing.
its for a motorcycle..
Slowly revealing information is a bad thing on this forum, as an answer can only be as good as the question, in this case not very good.
Please read this:-
How to use this forum
Now is this battery the one normally connected to a motorcycles other stuff. In which case it is unlikely to be 12V most of the time and that changes the calculation for the potential divider. Also it is likely to be noisy and therefore your Arduino will need some over voltage protection. Maybe the best bet is to use an opto isolator's LED and a resistor in parallel with your lamp. Then feed the other end into the Arduino and ground.
However given your track record of incomplete information, are you doing anything else with the Arduino that will require you to connect the Arduino's ground and the motorcycle's ground together?
Its for a gear indicator. I only want to check if there is any voltage on the "neutral" lamp. So I dont mind if the input is 3v or 4v or 5v. I guess that if I use analogue read and low the voltage (lets say) to 1v it will work.
Hi,
To clarify, why do you need to know if a lamp is ON.
What are you going to do with the signal you produce?
What is the application.
To really know if a lamp is ON, is to sense the light from it, not the voltage applied.
Tom.... ![]()
TomGeorge:
Hi,
To clarify, why do you need to know if a lamp is ON.
What are you going to do with the signal you produce?
What is the application.
To really know if a lamp is ON, is to sense the light from it, not the voltage applied.Tom....
I want to get signal from the lamp to know whether the gear has the "neutral" in it.
I cant sense the light since its exposed to daylight (sometimes I cant even say if its on or off during the daytime)
You'll have to look at the schematic for your particular vehicle, but something like the attached circuit is a probable solution. The switch is usually closure to ground, when closed the lamp is lit. To read the switch state you'd have a pullup resistor to Arduino power. The diode is to protect from vehicle 12 V having a path through the lamp to the Arduino input and +5 VDC. "Vout" is applied to a digital input to the Arduino.

@ MrMark - are you sure that the diode is the right way round?
Also that 10K resistor is in the wrong place. It won't protect the Vout from going to 12V.
Also using a catching diode like that is very poor practice for a permanent high voltage situation it is best suited for suppressing spikes.
The 10k resistor is a pullup for the switch, so ignoring the indicator lamp, the Arduino is seeing either a 10k pullup to +5 V or else it is seeing a switch to ground which is a pretty standard configuration.
The problem is when the switch is open there is a path from 12 V through the indicator light (modeled as ~100 ohms here) to the Arduino input. D1 is there to block that path so the Arduino input just sees the 10k pullup.
A more robust solution would be to have an additional series resistance to the Arduino input and a Zener diode to clamp the input as I've pictured in the attachment to this post, but the fundamental idea is the same as the previous post.

There are many ways to accomplish a goal. You have heard several that hook into the voltage system. But another (as you started out asking), Attach a light sensor directly over the light, and shield from sunlight. No need to worry about the 12/14v system then. If this is a show bike, then it would probably not be a pretty modification tho.
What is the end result? Do you want to turn on a buzzer, a bigger light, count how often you were in neutral in the last hour, or what?
@MrMark - Your advice falls way below the standard expected here.
Please try not to post bogus circuits, it does not help anybody.
@Grumpy_Mike - I'm not clear on what you think is wrong with the circuit described.
On the chance that I was missing the boat, I prototyped the circuit described in the second post, minus the zener, tested it and it seemed to work as I'd expected.
The signal at the Arduino input pin held at 5V with about 50 mV peak noise on it when the neutral safety switch was open and was, of course grounded when the switch was closed.
I used ~20k rather than 10k resistors because that's what I hand on hand and the first diode I pulled out of the parts bin, albeit with a quick check that it would withstand 12 V reverse biased.
The Arduino was on USB power from an automobile converter with a common ground at the motorcycle battery.
The code simply read from pin 2, wrote that value to pin 13, delayed a second, and repeated such that the pin 13 LED followed the (green) console indicator light.
Noise peaks at input pin were observed by finding the highest trigger level on an analog oscilloscope AC coupled. Spikes were on the order of 5 us long. Frankly it was cleaner than I expected.
Gratuitous photos are attached. My apologies for the poor quality, but it was getting dark and the flash washed out the indicator lights so the shutter speed was quite slow. The "In_Gear" photo is particularly bad because it involves holding the running bike up while operating the clutch and taking the photo.
All that said, using an opto-isolator is probably safer than any direct attachment of the microcontroller to the bike electrics and the parts count is about the same.


Um.... may I point out that the overwhelming consensus has the belief that the lamp can never fail.
although the OP said lamp, it appears we have not based all answers on what the OP has said in all other areas.
that being the case, what we want to know is when the transmission is in neutral.
based on that we know there is a switch. that switch completes a circuit and it would be very easy to sense power TO the lamp.
Also, since the application is a motorcycle and if the OP is anything like I was in my day, he moves that a little too for for an extension cord. ergo, we can take a fantastic leap of faith to assume the motorcycle is also the power supply. or that is should be.
that means that there is a common ground.
regardless, post #4 from Mr. Grumpy offers that an opto offers a way to use an LED, over a very wide range of input voltage, to get a signal.
and, since that signal will only be present while the bike is powered on and in neutral, we can also conclude that this circuit will have very little power drain.
as a test for the conclusion that the transmission is in neutral we have to jump to the conclusion that the lamp is fully functional.