Pulse Width Modulation (or PWM for short), is a technique for obtaining analog results with digital means. Digital control is used to create a square wave, a signal is switched between on and off. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED.This experiment is use PWM control LED’s on and off.
By changing the duty ratio to implement the brightness changes of LED.
This experiment is simple. It uses PWM to dim LED. We will pin 11 of GPIOs of pcDuino to realize the control.
useing loop statement controling LED
int led=10;//connection LED to the pin 10 //
void setup ()
for (int a=0; a<=255;a++)
//Increase the brightness of the LED //
delay(8); //Maintain 8 ms
//Maintain 8 ms
for (int a=255; a>=0;a–)
//reduce the brightness of the LED//
//Maintain 8 ms//
//Complete a cycle ,wait 800ms