# Stable PWM?

Hi!

I am trying to use a PWM signal to the base of a transistor to regulate current flowing through. I measure the current by measuring the voltage drop over a 15 Ohm resistor in series with the transistor.

However I can’t seem to measure the current properly. I think this is because of the PWM, since it’s sometimes high and sometimes low. What’s happening is that I’m sometimes getting (what I think is) reasonable numbers, like 40-60mA, but most of the time it just shows 0. If I set the base to HIGH I get 68mA constantly.

So I’m wondering if there’s an easy way to even out this, so that the analogRead gives me more of an average reading?

V=IR = .068A * 15ohm = 1.02V

With that much current flowing, you are morethan likely to damage the arduino pin eventually.
Change the resistor to 30 ohm or more.
V/R = I, 1.02V/30phm = 34mA, a much safer level.

The transisor will conduct at whatever level its load circuit will allow whenever the PWM output is high.
You can run the PWM thru a lowpass filter before going into the base of the resistor, that will help to smooth the PWM ripple out.
Basically this just involves putting a cap from the transistor base to Gnd as you have a series resistor already.
http://sim.okawa-denshi.jp/en/CRlowkeisan.htm