Skip to content

Instantly share code, notes, and snippets.

@dwhacks
Last active January 4, 2016 02:09
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 dwhacks/8553072 to your computer and use it in GitHub Desktop.
Save dwhacks/8553072 to your computer and use it in GitHub Desktop.
fade
/*Fade Up*/
for(byte i=1; i<100; i++) {
byte on = i;
byte off = 100-on;
for( byte a=0; a<100; a++ ) {
digitalWrite(led, HIGH);
delayMicroseconds(on);
digitalWrite(led, LOW);
delayMicroseconds(off);
}
}
/*Fade Down*/
for(byte i=1; i<100; i++) {
byte on = 100-i;
byte off = i;
for( byte a=0; a<100; a++ ) {
digitalWrite(led, HIGH);
delayMicroseconds(on);
digitalWrite(led, LOW);
delayMicroseconds(off);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment