dimming 12v halogen lamps

Hi! this my first post in the forum!

So I want to dim some halogen lamps depending on a proximity sensor.

I've been reading on this forum that I can dim a led with a transistor using PWM.

I don't really understand how a transistor works.. but I know from the high school days that it has 3 connectors.

So my questions are..

1) how do I connect the transistor to the 5v arduino and to the 12v halogen lamp?

2) will the fast pwm modulation work with an halogen lamp? I've read on other forums that halogen works on the same principle that incadescent. Some people say it will work but it will shorten the life of the bulb... what do you think?

On the coding side of things I'm pretty safe, the only thing that worries me is the electronic side which I know almost nothing about.

Any help is appreciated

TIA!

I found that FETs work better then Junctions for this. I tried something similar (dimming 12v LEDs) and it just would work with an NPN. Switched to FET and worked perfectly!

I found that FETs work better then Junctions for this. I tried something similar (dimming 12v LEDs) and it just would work with an NPN. Switched to FET and worked perfectly!

So how did you connect everything? Did you use a resistor?

TIA

There are two kinds of transistors, junction transistors and (newer) field-effect transistors (FETs) For a junction transistor, if you are switching a lamp (or LED) running from a +12V supply, you would connect an NPN transistor's emitter to ground; connect the base through a resistor to the Arduino output pin, and the collector to one side of the lamp. The other side of the lamp goes to +12V. (These diagrams show 24V, but the principle is exactly the same.)

Thanks for your input.

But... which resistor do I need to use for a 12v lamp?

I will simply give up halogen and try with a lep lamp.

But... which resistor do I need to use for a 12v lamp?

The resistor value in the MOSFET schematic is really controlled by the amount of current that can be supplied to the MOSFET base from the arduino pin. It has to be a sufficiently low value to be able to rapidly shut off the MOSFET, while still being sufficiently high as to not drag down the voltage being supplied to the MOSFET gate. As the digital pins on the arduino are fairly low current capable, I'd start with a range from 22k-47k ohms to see how it works.