Skip to content

Instantly share code, notes, and snippets.

@li2hub
Last active October 3, 2018 12:48
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 li2hub/544d41e6a1bc7c6bb0efb5452b5675e6 to your computer and use it in GitHub Desktop.
Save li2hub/544d41e6a1bc7c6bb0efb5452b5675e6 to your computer and use it in GitHub Desktop.
int r=255,g=0,b=0;
int d=5;
int redPin=D5;
int greenPin=D6;
int bluePin=D7;
void setup() {
pinMode(redPin,OUTPUT);
pinMode(greenPin,OUTPUT);
pinMode(bluePin,OUTPUT);
}
void loop() {
for(int i=0;i<255;i++)
{
analogWrite(redPin,r);
analogWrite(greenPin,g);
analogWrite(bluePin,b);
r-=1;
g+=1;
delay(d);
}
for(int i=0;i<255;i++)
{
analogWrite(redPin,r);
analogWrite(greenPin,g);
analogWrite(bluePin,b);
g-=1;
b+=1;
delay(d);
}
for(int i=0;i<255;i++)
{
analogWrite(redPin,r);
analogWrite(greenPin,g);
analogWrite(bluePin,b);
b-=1;
r+=1;
delay(d);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment