Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ignition domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /dom953964/wp-includes/functions.php on line 6131

Deprecated: Return type of GD_WordPress_File_Iterator_Filter::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /dom953964/wp-content/plugins/wp_migration-master/classes/iterators.php on line 5

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the health-check domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /dom953964/wp-includes/functions.php on line 6131
RGB Color Fade – Lara Grant

RGB Color Fade

INPUT: Button
OUTPUT: RGB LED

DESCRIPTION: Push button, LED fades through colors.

[code lang=”arduino” light=”true”]

// when button is pushed, led fades through colors
//
// LilyPad RGB LED is common anode so inverse values for common cathode LEDs
//

int redPin = 9;
int greenPin = 11;
int bluePin = 10;
int buttonPin = 2;

int fadeSpeed = 15; // make this higher to slow down

void setup() {
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode (buttonPin, INPUT_PULLUP);

}

void loop() {
int buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
int r, g, b;

if (buttonState == LOW) {
digitalWrite(redPin, LOW);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin,LOW);

// fade from violet to red
for (b = 0; b < 255; b++) {
analogWrite(bluePin, b);
delay(fadeSpeed);
}
// fade from red to yellow
for (g = 255; g > 0; g–) {
analogWrite(greenPin, g);
delay(fadeSpeed);
}
// fade from yellow to green
for (r = 0; r < 255; r++) {
analogWrite(redPin, r);
delay(fadeSpeed);
}
// fade from green to teal
for (b = 255; b > 0; b–) {
analogWrite(bluePin, b);
delay(fadeSpeed);
}
// fade from teal to blue
for (g = 0; g < 255; g++) {
analogWrite(greenPin, g);
delay(fadeSpeed);
}
}
else{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin,HIGH);

}

}
[/code]

Leave a Reply