Skip to content

Instantly share code, notes, and snippets.

Created May 10, 2017 17:45
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anonymous/d4fa3719478c3c5a9c321cc372e95407 to your computer and use it in GitHub Desktop.
Save anonymous/d4fa3719478c3c5a9c321cc372e95407 to your computer and use it in GitHub Desktop.
//Code created by Ian Buckley for an article on makeuseof.com
//define pins for the red, green and blue LEDs
#define RED_LED 6
#define BLUE_LED 5
#define GREEN_LED 9
//overall brightness value
int brightness = 255;
//individual brightness values for the red, green and blue LEDs
int gBright = 0;
int rBright = 0;
int bBright = 0;
int fadeSpeed = 10;
void setup() {
//set up pins to output.
pinMode(GREEN_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
pinMode(BLUE_LED, OUTPUT);
//Call the TurnOn method, wait, then call TurnOff
TurnOn();
delay(5000);
TurnOff();
}
void TurnOn(){
for (int i=0;i<256; i++){
analogWrite(RED_LED, rBright);
rBright +=1;
delay(fadeSpeed);
}
for (int i=0;i<256; i++){
analogWrite(BLUE_LED, bBright);
bBright += 1;
delay(fadeSpeed);
}
for (int i=0;i<256; i++){
analogWrite(GREEN_LED, gBright);
gBright +=1;
delay(fadeSpeed);
}
}
void TurnOff(){
for (int i=0;i<256; i++){
analogWrite(GREEN_LED, brightness);
analogWrite(RED_LED, brightness);
analogWrite(BLUE_LED, brightness);
brightness -= 1;
delay(delay(fadeSpeed);
}
}
void loop(){
}
@phaze3131
Copy link

does not work, error line 67

@HannimalCrackers
Copy link

Line 67 should read: delay(fadeSpeed);

@juziplex
Copy link

Zeile 17 wird Fehler angezeigt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment