Finally made a glowing candle :) (RGB one!) (With Video?) (now with code! LOL) :

and i only had 1 issue with the code from start to finish :smiley: - getting used to this C/C++ thingy now... still wish i had a pascal compiler though lol

Theoretically, Pascal would be possible using GNU Pascal.

Great, but it's a little late, i've just about got the knack of it to write large portions of code without refering to help files.

So, meh why make it any more difficult for myself.

But did you like the effect? too slow? too fast?

int ledPin1 = 9;  
int ledPin2 = 10;
int ledPin3 = 11;// LED connected to digital pin 9
int val = 0;         // variable to store the read value
boolean firstcycle = false;

void setup()
{
  pinMode(ledPin1, OUTPUT);   // sets the pin as output
  pinMode(ledPin2, OUTPUT);   // sets the pin as output
  pinMode(ledPin3, OUTPUT);   // sets the pin as output
  
}

void loop()
{
  int n;
  int n2;
  int n3;
   delay(3000);
   digitalWrite(ledPin1,LOW);
   digitalWrite(ledPin2,LOW);
   digitalWrite(ledPin3,LOW);   
//  val = analogRead(analogPin);   // read the input pin
  n2=255;
  if (firstcycle==false) {
  for (n=0; n<255; n++)
  { 
     analogWrite(ledPin1, n);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
     delay(15);
     n2--;
    }
  }


  n2=0;

  for (n=255; n>0;)
  { 
     analogWrite(ledPin1, n);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
     analogWrite(ledPin2, n2);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255     
     delay(15);
     n--;
     n2++;
  }


  n2=255;
  for (n=0; n<255;)
  { 
     
     analogWrite(ledPin2, n2);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
     analogWrite(ledPin3, n); 
     delay(15);
     n++;
     n2--;
  }



 for (n=255; n>0;)
  { 
     analogWrite(ledPin3, n);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
     analogWrite(ledPin1, n2);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255     
     delay(15);
     n--;
     n2++;
  }
  
  firstcycle=true;

}

your thoughts :slight_smile:

still wish i had a pascal compiler though

And hence the user name :slight_smile:

cjdelphi:
your thoughts :slight_smile:

OK - here are my two cent: If it works for you and you are satisfied, then it's OK. It's (mostly ;)) well formatted - this helps to understand the program. I have only two remarks:

  1. the for loops for (n=255; n>0;) are a little bit unusual. Why did you put the n-- into the loop and not into the for statement?

  2. I think the part "if (firstcycle==false)" may go into the setup function (without the "if"). Then you can spare a boolean (not really necessary here, but memory on µC is tight ;)).

Thumbs up!

best regards
Andreas

It looks pretty realistic. Well done!

Of course, normal candles aren't multi-colour, that's over egging the pudding, eh? But a nice effect.