Deryoung Electronics
         arduino lab note
 
Welcome to ... Guest! Not yet Open Comming Soon | Login

Pulse Width Modulation

//*************************************
//Program:pwm.pde
//Crate by:Deryoung.com
//Resulte: LED fade-in and out
//Interface: LED pin(+) to digital-9 and pin(-) to Ground
//*************************************
int ledPin = 9;    // LED connected to digital pin 9

 void setup()  { 
   // nothing happen here!
 } 

 void loop()  { 
   int i; // time for fade-in/out
   
   for(i=0;i<=255;i+=5) { // count up from 0 to 255,with 5+ step
     analogWrite(ledPin,i);
     delay(10);
   }
   for(i=255;i>=0;i-=5) { // count down from 255 to 0,with 5- step
     analogWrite(ledPin,i);
     delay(10);
   }
   
 }
This website is personally and all reserved right of meterial, you can copy and use its with refer link to this site
Email contact : support@deryoung.com