Example Code for Arduino-LED Dimming

Last revision 2025/12/23

The code below shows how to make LEDs change their light between dark to bright circularly. And it can be more beautiful if your LEDs have different kinds of color.

Hardware Preparation

Name Model/SKU Quantity Purchase Link
LED - 3 -
Nova Board KIT0042 1 DFRobot

Software Preparation

  • Development tool: Arduino IDE (download link: https://www.arduino.cc/en/software)
  • Required library: None (uses built-in functions)

Wiring Diagram

  • LED1 → D9 (Arduino)
  • LED2 → D10 (Arduino)
  • LED3 → D13 (Arduino)

Other Preparation Work

Ensure the Nova board is connected to your computer via Micro USB.

Sample Code

// # Editor    :Holiday from DFRobot
// # Data      :08.06.2013

// # Product name:Nova
// # Product SKU:Unknown
// # Version : V2.0

// # Description:
// # This sample shows how to use the Nova for LED controlling

// # Connection:
// # LED1,LED2,LED3 ->D9,D10,D13 (Arduino)

void setup()
{
  pinMode(9,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(13,OUTPUT);
}
void loop()
{
  for (int i=0;i<255;i++)
  {
    analogWrite(9,i);                    //LEDs will be brighter with a rising "i"
    analogWrite(10,i);                   //"i" means the value of PWM
    analogWrite(13,i);
    delay(10);
  }
  delay(100);
  for(int i=255;i>0;i--)
  {
    analogWrite(9,i);                   //LEDs will be darker with a declining "i"
    analogWrite(10,i);                  //"i" means the value of PWM
    analogWrite(13,i);
    delay(10);
  }
}

Result

LEDs will change their light between dark to bright circularly.

Was this article helpful?

TOP