Help with RGB LED Fire Effect

Hello :slight_smile:

Wanted to make a pumpkin light with the arduino using RGB leds, after getting insperation from Project 9 of Earthshine Design Arduino Starter Kit Manual (download if you have not...is brilliant)

truble is this code is for 2xyellow, and 1xRed leds...and i have no yellows :frowning:

Soooooo was wondering if someone could help me with changing the code to have one of the RGB set as yellow, and one set as Red.

// Project 9 - LED Fire Effect
int ledPin1 = 9;
int ledPin2 = 10;
int ledPin3 = 11;
void setup()
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}
void loop()
{
analogWrite(ledPin1, random(120)+135);
analogWrite(ledPin2, random(120)+135);
analogWrite(ledPin3, random(120)+135);
delay(random(100));
}

AND THEN!!!!!!!!!

what would be really cool is to have them flickering for 30 seconds ten both switch to a spooky bright green for 5 and loop!

So far iv got....this mess

// RGB Flames
int ledPin1 = 3; // R
int ledPin2 = 5; // G
int ledPin3 = 6; // B

int ledPin4 = 9; // R
int ledPin5 = 10; // G
int ledPin6 = 11; // B
void setup()
{
pinMode(ledPin1, OUTPUT); // R
pinMode(ledPin2, OUTPUT); // G
pinMode(ledPin3, OUTPUT); // B

pinMode(ledPin4, OUTPUT); // R
pinMode(ledPin5, OUTPUT); // G
pinMode(ledPin6, OUTPUT); // B
}
void loop()
{
analogWrite(ledPin1, random(120)+135); // RED
analogWrite(ledPin4, random(120)+135); // RED (red + green =YELLOW
analogWrite(ledPin5, random(120)+135); // GREEN (green + red = Yellow)

delay(random(100));
}

The trouble is I will need the pin4 (red) + pin5 (green) to flicker at the same rate to keep a constant yellow huge... :o

well for a starter ...

yellow is a mix tween Red and green

Get a feel for the Color Wheel.

well for a starter ...

yellow is a mix tween Red and green

Ummmmmm.....yes i Know yellow is a mix of Red and Green, hence me putting that in my code that the red + Green Diodes have to be on in the same LED to make yellow(look at the pin numbers, one LED is RED, another LED is GREEN + RED = YELLOW.....but was asking how to make them flicker at the same rate as the colour will change from yellow if one becomes brighter then the other.

analogWrite(ledPin4, random(120)+135); // RED (red + green =YELLOW
analogWrite(ledPin5, random(120)+135); // GREEN (green + red = Yellow)

sorry, i am doing a "head scratching" session myself and did not see that part or fully understand the question :-[

the quickest thing that comes to mind is

sudo

int yellow = random(120) + 135);

analogWrite(ledPin1, random(120)+135); // RED
analogWrite(ledPin4, yellow); 
analogWrite(ledPin5, yellow);

so that green and red can't over-mix each other

I dont have any rgb led's (oddly enough i do have a couple dual color red / yellow ones) or i would try it