Reflection
*Code follows*
//rgb colour fade
#define GREEN 3
#define BLUE 5
#define RED 6
#define delayTime 1000
//red & yellow LED Fire Effect
int ledPin1 = 10;
int ledPin2 = 9;
int ledPin3 = 11;
int ledPin4 = 8;
int ledPin5 = 7;
//rgb colour fade
int redVal;
int blueVal;
int greenVal = 0;
int pin1Milli;
int pin2Milli;
int pin3Milli;
int pin4Milli;
int pin5Milli;
bool fadeDirection = true;
void setup()
{
//red & yellow LED Fire Effect
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
//rgb colour fade
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(RED, OUTPUT);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
digitalWrite(RED, HIGH);
pin1Milli = random(120)+135;
pin2Milli = random(120)+135;
pin3Milli =random(120)+135;
pin4Milli =random(120)+135;
pin5Milli =random(120)+135;
Serial.begin(9600);
}
void loop() {
//red & yellow LED Fire Effect
if(millis() >= pin1Milli)
{
analogWrite(ledPin1, pin1Milli);
pin1Milli = random(120)+135;
}
if(millis() >= pin2Milli)
{
analogWrite(ledPin2, pin2Milli);
pin2Milli = random(120)+135;
}
if(millis() >= pin3Milli)
{
analogWrite(ledPin3, pin1Milli);
pin3Milli = random(120)+135;
}
if(millis() >= pin4Milli)
{
analogWrite(ledPin4, pin1Milli);
pin4Milli = random(120)+135;
}
if(millis() >= pin5Milli)
{
analogWrite(ledPin5, pin4Milli);
pin5Milli = random(120)+135;
}
//rgb colour fade
redVal = 255;
blueVal = 0;
if(millis() >= delayTime && fadeDirection == true)
{
greenVal += 1;
analogWrite( GREEN, greenVal );
analogWrite( RED, redVal );
Serial.println(greenVal);
analogWrite( BLUE, 0 );
if(greenVal == 30)
{
fadeDirection = false;
}
}
else if(millis() >= delayTime && fadeDirection == false )
{
greenVal -= 1;
analogWrite( GREEN, greenVal );
analogWrite( RED, redVal );
analogWrite( BLUE, 0 );
Serial.println(greenVal);
if(greenVal == 0)
{
fadeDirection = true;
}
}
}
I got the idea from the old heaters that looked like a fireplace.