A simple Arduino Uno LED fade program

Shortly after writing my Arduino Uno Hello, World example, I read my documentation a little more, learned that Pin 9 on the Arduino Uno board is an analog pin, switched the LED wire to that pin, and created the following program, which slowly lights up the LED using an analog programming approach, and then fades the LED light out.

Here's the source code for my LED fade sketch:

// a simple arduino uno 'led fade' program (sketch)

// pin 9 is an analog pin
int led = 9;

void setup() {
  pinMode(led, OUTPUT);

void loop() {
  int delayTime = 10;
  // slowly turn the led on
  for (int i=0; i<255; i++) {
    analogWrite(led, i);
  // slowly turn the led off
  for (int i=255; i>0; i--) {
    analogWrite(led, i);

  // another delay here, not really needed  

If you're used to C programming, there isn't too much to say about this Arduino LED fade sketch, so I won't write much about it at this time. But if you have any questions, just leave a comment below, and I'll be glad to answer any questions.

One thing that is important to say is that this example assumes the following:

  • You are using an Arduino Uno controller.
  • You have an LED connected to Pin 9 of the Arduino Uno.
  • You have everything properly connected on your breadboard. See this YouTube video for how my system is currently wired. The only difference in my Arduino Uno wiring is that I moved the LED wire from Pin 13 to Pin 9, which is an analog pin.

I hope this simple Arduino Uno LED Fade program is helpful. If you're an Arduino newbie like me, the more good examples you can find, the better.