I am trying the following circuit as a part of a project. The goal is to turn on and off the transistor, S8050 (datasheet) at a certain time interval (say 1s), and read the value of the collector current (Ic). I am controlling the base voltage of the transistor using ARDUINO PWM. When my transistor is off I am getting zero Ic current which is fine. But when I turn the transistor on the IC current is fluctuating from 19mA to 45mA. My question is how can I get a fixed Ic current?
I tested the circuit putting base voltage 0V and at that time Ic is Zero. Also, put the 5V to the base and got 33mA. This fluctuation arises when I'm turning ON and OFF the transistor using the PWM.