Last active
October 3, 2018 12:48
-
-
Save li2hub/544d41e6a1bc7c6bb0efb5452b5675e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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