RGB color fade - Fire/Flame emulation

Hi guys,

I'm working on making a night light for my son and am in need of some suggestions. the night light is a space rocket and I'm looking to install leds in the bottom to emulate a rocket engine flame.

Planning on using 3 common anode RGB leds driven with pwm through transistors. (each colour has its own transistor).

however when it comes to modelling the lighting with the code I'm having some problems.

My question is this. If you had to design the code to drive the leds to emulate fire/flames, what method would you use? (using only red and green leds to create red to yellow spectrum.)

My current idea is to just select the colours I want it to fade through and just code each colour manually.

I have been playing with the fader example and got some ok results. However the led keeps dropping to a solid green for a split second and I don't want that. Code is below ;

Are there any other methods I could use to achieve the goal?

int redLed = 5;
int greenLed = 6;
int blueLed = 9;
int fadeRed = 5; // red Fade 
int redBrightness = 0; // Red brightness
int fadeGreen = 5; // green Fade
int greenBrightness = 0; // Green Brightness

void setup() {
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);

}

void loop() {
  
  analogWrite(5, redBrightness);
  analogWrite(6, greenBrightness);
  
  redBrightness = redBrightness + fadeRed;
  
  if (redBrightness == 150|| redBrightness ==255) {
    fadeRed = +fadeRed;
  }
  greenBrightness = greenBrightness + fadeGreen;
  
  if(greenBrightness ==0|| greenBrightness ==20) {
    fadeGreen = -fadeGreen;
  }
    delay(100);
  

}

Sideways, I know... but I have found that the best night light colour is blue. The reason is, it can't be seen with the eyelids shut (they are an effective red filter). So it's the best of both worlds - it can be extremely bright with eyes open, and completely dark with eyes closed. Flickering or blinking can not be seen with the eyes closed.

Do you want a fast random change of light, or only a soft and slow change ?
Some leds simulate a candle, and it seems very good.

I think the rocket flames should have some random intensity, and a slight random change of red/yellow color. The main calculation should be the intensity, and the greed led should only be a certain (random) percentage of that intensity.

I tried to simulate a heartbeat with a led. A double 'bell' shape. I'm using a fixed 25Hz update rate with millis(), and the calculation is is with float. The 'bell' shape is 100 * exp ( -10 * x * x ).

aarg:
Sideways, I know... but I have found that the best night light colour is blue. The reason is, it can't be seen with the eyelids shut (they are an effective red filter). So it's the best of both worlds - it can be extremely bright with eyes open, and completely dark with eyes closed. Flickering or blinking can not be seen with the eyes closed.

Are you sure? Can't it delay the sleep?
Maybe fade the light to darker when the time passes.