I'd like to know why I cannot dim the small LED strip with my design. I can only turn them on and off. This is a problem for me as I wanted to have a fade effect. Here is my circuit:

Circuit using fritzing

The voltage from the power jack is 5 volts. My NPN transistor is a 2N3904 (from left to right: emitter, base, collector). For the Arduino I am only using the fade exemple sketch:

int led = A2; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
   pinMode(led, OUTPUT);

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 9:
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
     fadeAmount = -fadeAmount;
  // wait for 30 milliseconds to see the dimming effect

By the way, this is my first post so please tell me if something is wrong with it! Thank you for your help!

Have a nice day.

  • The voltage from the power jack is 5 volts - what do you mean by that? Are you feeding 5V into that thing at the top of the picture (into Vin?). I'm a little surprised the LEDs light up at all, since the forward voltage for a red LED is around 2V, and with 5 in series, they will be getting 1V each.
    – Nick Gammon
    Dec 28, 2017 at 5:24

1 Answer 1


The analogWrite works only on PWM pins (in your scheme it's marked by ~). On the other pins it's possible to set only LOW/HIGH (values under 128 are translated to the LOW)

Not to mention weirdly used NPN with LEDs as negative feedback. But that's why it doesn't burned out yet. The usual way is connect the Emmiter to the ground and base is driven over current limiting resistor (about 1k). This is how we usualy use PNP transistor (again with 1k resistor and emitter to the Vcc, not the collector). But PNP won't work with 5V logic and higher Vin than 5V as there will be current flow from 0V or 5V to the Vin.

  • The unusual NPN connection you show is called an emitter follower circuit. The emitter will follow the base voltage -.7V or -1.4v for a darlington. I assume you are powering it by the USB.
    – Gil
    Sep 23, 2020 at 3:49
  • @gil He has 5 LEDs in series (roughly about 9V @ 10mA) and emmiter follower with 0 or 5V in the base...
    – KIIV
    Sep 24, 2020 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.