12v Pulse signal to 5v pulse signal

Hi, can anyone help me. I have a 12v pulse output from a sensor device, which I need to convert to a 5v pulse signal so that it can be read by a digital pin as 'high' on my arduino UNO. I have limited knowledge about arduino all in all, but I've got this far and I'm stuck.
I don't want to send the 12v signal straight to the arduino, as I've researched it and found that this could significantly damage the board, so I need to reduce it to a 5v signal.
I have various circuit boards lying around with mosfets and resistors on, but not really sure what type I'm looking for to use.
Would be really great if someone could help me in the right direction.
Thanks,
Jack :slight_smile:

I'd try a voltage divider

Two resistors as a voltage divider. See Voltage Dividers - SparkFun Learn

Steve

Thanks Slipstick, will give it a go. I have used the spark fun calculator and found that I need 1x 6.8k resistor and 1x 4.7k resistor, so I will look to buy some of them and give it a go, thanks for your help :slight_smile:

Hi, I have just looked through for the right resistors and I can't find the right ones. But I have found loads of different mosfets, do you reckon one of those could be used instead?
Many thanks,
Jack

Or you could just use a transistor as buffer.
Transistor base pin looks like a diode to Gnd for the 12V signal, size the resistor for appropriate current.
1K will draw about 10mA from the 12V source:
(12V - 0.7V)/1000 = 11.3mA

N-channel MOSFET will work the same same way, with smaller current load on the 12V source, mere uAs.

Hi, thanks for your reply. I have very little experience of electronics, so I'm struggling to understand quite what you mean. I have found one of these transistors KTC2027 TRANSISTOR Datasheet pdf - NPN TRANSISTOR. Equivalent, Catalog
would this be of any use?
Many thanks.

Yes, that would work. Wire it up per the left hand diagram.

Resistor connects to the Base, Collector to the Arduino pin, Emitter to the 12V and Arduino Gnds.

Hi, thanks for that, As I am a total beginner, I am having some issues reading my pin states for the digital pins.
I will need to be able to read the pins for when the transistor is all connected up. Attached is my code which checks the pin state of pin 8. then if the pin state is high it blinks the led. But I have connected pin 8 to ground to make it low, but the led still blinks. What am I doing wrong?!!

blink_led_and_test_inputs.ino (406 Bytes)

The ; here

if (val == LOW);

... ends the if() prematurely, so the code you think is conditional, the blink stuff, runs all the time.

Lose the ;

rhsv_muckerjee Many thanks for your help - working properly now!

CrossRoads, is it a 1k resistor I need to connect to the base, where does the other end of the resistor connect to?
Thanks

One end is your 12V signal, the other end is the base of the transistor.

jack789_arcademan:
Hi, thanks for your reply. I have very little experience of electronics, so I'm struggling to understand quite what you mean. I have found one of these transistors KTC2027 Datasheet, NPN TRANSISTOR.
would this be of any use?
Many thanks.

That one is overkill. You don't need a 4A collector current to pull down a 30k resistor to VCC. Any general purpose small signal NPN like 2N2222A or 2N3904 would do.

Two things not mentioned. The transistor will invert the signal logic so a 12V will produce a logic LOW and 0V will produce a logic HIGH. Also your input has to be <= 0.6 volts for the transistor to turn off. The MOSFET has a similar, but different valued threshold.

For the BJT circuit, 1k is lower than it needs to be. You can use 10k or more and it will draw less power from the 12V.

Hi all, thanks for your guidance. I have decided to buy a 12v relay module as I think it should work in the way I need it to. Thanks for your help.

jack789_arcademan:
Hi all, thanks for your guidance. I have decided to buy a 12v relay module as I think it should work in the way I need it to. Thanks for your help.

I doubt that. Most modules have 5V on the input side, not 12V.

12V relay module usually means the relay coil needs 12V to energize instead of 5V.

CrossRoads:
12V relay module usually means the relay coil needs 12V to energize instead of 5V.

Yes, but for the OP application only a relay is needed. None of the logic level driver circuit can be used without some mods to essentially disable it. Also for their application they don't need such a huge relay.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.