# Read a 12V pwm with Arduino

Hi there!

Quite new to electronics, so please be gentle!

I need to read a 12V pwm signal in my project. How do I convert it to a 5V pwm for me to read it using the pulseIn(...) function.

I found this: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232444802, but in fact I do not understand what to do with the resistor, transistor. (how to connect them) Wouldn't a normal voltage divider circuit suffer?

Could any of you guys point me in the right direction?

Yes, I see no reason a simple two resistor voltage divider wouldnâ€™t do the job just fine.

Lefty

retrolefty: Yes, I see no reason a simple two resistor voltage divider wouldn't do the job just fine.

Thank you very much.

Your welcome. Just remember to connect the grounds together from the 12vdc system/voltage divider and arduino ground pin.

would a zener diode also work to protect the input on the arduino ?

what would happen if the 12v signal went to say 100v by accident

Gadget999: would a zener diode also work to protect the input on the arduino ?

Yes that is another method, one say 4.7vdc zener diode and one current limiting resistor would 'chop' the +12vdc signal to a 0 - 4.7vdc signal.

what would happen if the 12v signal went to say 100v by accident

If using a voltage divider a 100vdc could cause destruction of the arduino chip. If using the zener maybe nothing or destruction of the series current limiting resistor.

I like the zener + resistor solution over the two resistor divider solution.

I like the zener + resistor solution over the two resistor divider solution.

Ok, if it will protect my arduinos input it is maybe the way to go. So here's another newbie question:

I should connect the Zener in parallel with the input and ground. But where should I place the resister? And how will I calculate the value of the resistor?

I should connect the Zener in parallel with the input and ground.

But where should I place the resister?

Between input pin and source of 12vdc PWM signal.

And how will I calculate the value of the resistor?

Not critical in this application, 1k ohms should work fine.

Lefty

Thanks again Lefty!

Lefty would a 1k resistor protect against bigger voltages like 50 v ?