Chapter 17 – Experiment 10 – FADING LEDS

Until now we were always using the leds available in the kit switching them on or off, probably not always what we need, with this experiment we will use the capacity of the microcontroller to “fade” a led and learning the power of the PWM (Pulse Width Modulation) to control a device. The PWM normally is used to manage device like computer fans or other appliances that are not necessary on or off.

fading-led

schema-fading-led

int led = 9;
int brightness = 0;

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

void loop()
{
for(brightness=0;brightness<=

255;brightness++)
{
analogWrite(led,brightness);
delay(500);
}
}

Homework 1

Try to slow down the fading of the LED.

Homework 2
After that you tried the circuit and the code using one led, try to add a second led and after a third one. As tip we suggest to check the experiments that were using more than one led to understand how to modify the code for this homework.

Homework 3
When you are able to use two leds, try to use the RGB led included in the kit to fade all the three colors of the RGB led.

1 comment

  1. [...] 15 – Experiment 08 – INTERACTIVITY Chapter 16 – Experiment 09 – STORE DATA FOR LONG TERM Chapter 17 – Experiment 10 – FADING LEDS Chapter 19 – Experiment 11 – DISCO PARTY (RGB LED) Chapter 20 – Experiment 12 – IS MY [...]

Leave a Reply to WE MAKE IT – The Manual | WMKIT Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


istanbul evden eve nakliyat istanbul evden eve nakliyat istanbul evden eve nakliyat sarıyer evden eve nakliyat beylikdüzü evden eve nakliyat şişli evden eve nakliyat