Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arduino RGB LED Fire Simulation. Don't look directly into the LED, it is meant to be reflected in something like a model furnace.
// Set the Pins for LED
int green = 10;
int blue = 9;
int red = 11;
void setup()
{
//Configure Pins as Output
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(red, OUTPUT);
}
void loop() {
//Generate Random Number to set brightness
int brightness = random(120);
//Use brightness and filler to set Red to high visibility
analogWrite(red, brightness+135);
//Use green and blue in a very low percentage to get some orange glowing into the "fire"
analogWrite(green, brightness/7);
analogWrite(blue, brightness/17);
//create a little bit of flickering
delay(random(100));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment