Introduction: Control an LED With PWM Output

Picture of Control an LED With PWM Output

As you may have noticed in the Arduino board (Uno, Mega-etc.) Are present some PIN that have next a symbol like a wave.

This symbol indicates that the output can also be used in "PWM" or "Pulse-width modulation".
Using this function, it is possible to vary, for example, the frequency of switching on and off of an LED.

Step 1: The Circuit

Picture of The Circuit

First we need to:

- Arduino Uno

- A resistor 220Ohm


- Breadboard

- Wires for links

Mounted the circuit as described in the picture

Step 2: The Sketch

Picture of The Sketch

// Created by //

// Alessio Bigini 2015 //

// //

int lum = 0;

void setup()


pinMode(9, OUTPUT);


void loop()


for (lum = 0; lum < 255; lum++ )


analogWrite(9, lum);



for (lum = 255; lum > 0; lum-- )


analogWrite(9, lum);




Now load the sketch into your board

In this code I used two simple For loops that allow me to increase the variable "Lum" from 0 to 255 and then decrease it.

Step 3: The Video


Moe Odatalla (author)2015-06-27

He published it, and I found it through his channel. I just wanted to thank you for making this instructable, and for sharing. I found this very informative.

Thanks you so much!

JRV31 (author)2015-03-03

I am considering building a collection of instructables on beginning Arduino.

Do I have your permission to include this instructable?

dev.alessiobigini (author)JRV312015-03-03

Yes sure?

JRV31 (author)dev.alessiobigini2015-03-03

It's added to my collection, I,ll let you know when I publish it.

About This Instructable




More by dev.alessiobigini:Print Flexible Filament With Creality CR-103D Printed Tunnel Carpal TutorLEDFader Arduino Library
Add instructable to: