Transistor to control 12V through PWM (Just checking)

Quick summary first. I want to generate a pulse, but it needs to be 12v.

So - the arduino controls a single pin on a transistor, that is hooked up to 12v, and I can create the pulse that way.

Just checking before I dig further - this is correct?

Context :

I am building a piece of art (though I'm a technical guy), and part of it is a Harley Davidson electronic speedo. I will have a light sensor to turn the internal lighting on and off, and a motion detector to sense if someone is near - and if so make the speedo accelerate (I will generate a pattern in time - not just up and down, but something interesting).

So, the key here is providing the pulse to the speedo, which has to be 12v. Hence my question - I believe I am 'barking up the right tree' to create this pulse, but can someone please just sanity check me?

ps, this is my first project at this level. Been an IT guy for years (ok, decades), but this is my first foray into bare bones electronics,.....

Thanks :D

You need to connect the drive circuit to a resistor connected to the transistors base (NPN) Emitter to ground (common) Collector to a suitable collector resistor (example 1K) the other end of the resistor to +12V Collector is the O/P.

Examples HERE

Just remember: The base current of the transistor times the gain of the transistor will roughly equal the collector current; so care must be exercised to use the right resistor value(s) to ensure that you do not exceed the per-pin current of the microcontroller.

I strongly recommend that you become familiar with the online SPICE tool:

Using SPICE, you can easily build and virtually test all manner of electrical and logic circuits. You can even download the entire JAVA package to your PC to use when away from Internet connectivity. Projects can be saved as text files and loaded as text files; locally or online.


Thanks both for the advice!

I know now at least I am on the right path, just need to get the values for resistors right and we should be there.

A secondary question - I know lots of diagrams for motors have a diode as well to ensure there is no voltage return from a motor - this isn't a DC motor, but is it wise anyhow?

What kind of motor is it? The simple transistor may not be the right thing.


It's not a motor at all (I guess...), it is a digital speedo from a motorcycle... And since the unit is sealed, I cant just apply a voltage (to create the impression of speed), but have to supply a pulse like the pulse coming from the real speedo sensor on the bike... (This is just for a wall mounted something or other, so not 'real')

If you're driving an inductive load then it has electrical inertia - if you try to reduce the current then the collapsing magnetic field will produce a forward EMF which tends to keep the current flowing. If you try to switch it off abruptly by turning off a transistor, this can generate a high enough voltage to damage the transistor. The usual solution to this is to connect a reverse biased diode in parallel with the inductive load. This diode provides a path for current to continue flowing through the load when you stop the supply current, so that the current can dissipate smoothly rather than trying to stop abruptly.

This problem and its solution would apply to any DC load which is inductive, such as motors, solenoids, relays. I think you'll probably find the speedometer you're driving has a coil in it, which means it will be an inductive load.