Skip to content

Instantly share code, notes, and snippets.

@wakasann
Created November 24, 2016 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wakasann/86177dc08eceb9b5f3d363e7cae9f4e8 to your computer and use it in GitHub Desktop.
Save wakasann/86177dc08eceb9b5f3d363e7cae9f4e8 to your computer and use it in GitHub Desktop.
int brightness =0; //defined the int var brightness and set the init value,it is use to show the led light
int fadeAmount = 5; //defined int var fadeAmount,it use to set the light add/mins count
void setup()
{
pinMode(9,OUTPUT); //set the prot 9 is output port
}
void loop()
{
analogWrite(9,brightness); // set the port 9 use brightness
brightness = brightness + fadeAmount; //change the brightness value,make led light can next loop change
if(brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount; //make the light can high or low
}
delay(30); //delay 30 seconds
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment