//example PWM sketch //globals int ledPin = 9; void setup(){ pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); }//end of setup void loop(){ //increasing the LED brightness for(int bright=0; bright<=255; bright=(bright+5)){ analogWrite(ledPin, bright); delay(20); }//end of increasing bightness //decreasing the LED brightness for(int dim=255; dim>=0; dim=(dim-5)){ analogWrite(ledPin, dim); delay(20); }//end of decreasing brightness }//end of loop