Arduino Uno: Driving a small LED strip with 2N3904 NPN 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:



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 &lt;= 0 || brightness &gt;= 255) {
     fadeAmount = -fadeAmount;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}


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 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.