I say real... but it's obviously not, how close to a real effect is the question
What is the code ?
And a schematic ?
cjdelphi,
Are you seeking opinion?
i used some other guys code and tinkered with it, using the first 5 pins, i changed the delay
and got this.... i think its very similar to a real candle flame, i need to modify it to check
to see if any of the flames are out and start them up before it gets too dark as the delay
could be short enough to become really bright and then really dark too quickly...
anyway.
// Fade all IO by Osamu Iwasaki
// November 10, 2010
#include <MsTimer2.h>
#define OUT_MIN 2 // First pin
#define OUT_MAX 9 // Last pin (this includes the analog pins)
byte luminance[20];
byte lumi[20] = {};
void setup()
{
int i;
for(i = OUT_MIN; i <= OUT_MAX; i++){
pinMode(i, OUTPUT);
digitalWrite(i,LOW);
}
for(i = OUT_MIN; i <= OUT_MAX; i++){
digitalWrite(i,HIGH);
delay(150);
}
for(i = OUT_MIN; i <= OUT_MAX; i++){
digitalWrite(i,LOW);
//delay(50);
}
delay(100);
MsTimer2::set(1, int_pwm);
MsTimer2::start();
}
void int_pwm() {
static int f_wait[20];
static int f_max_time[20];
static int f_speed[20];
static int f_ct[20];
static long f_interval[20];
static int ch;
for(ch = OUT_MIN; ch <= OUT_MAX; ch++){
if(f_wait[ch] == 0){
f_wait[ch] = f_speed[ch] + 1;
if( (f_ct[ch] < 255) )
if(luminance[ch] != 255)
luminance[ch] ++;
if(f_ct[ch] == 255){
if(f_max_time[ch] == 0)
f_max_time[ch] = 0; // On Max Time
else
f_max_time[ch] --;
}
if( (f_ct[ch] > 255) && (f_ct[ch] < 511) && (f_max_time[ch] == 0))
if(luminance[ch] != 0)
luminance[ch] --;
if(f_ct[ch] >= 511){
if(f_interval[ch] == 0){
f_interval[ch] = 200; // fading seed
f_speed[ch] = random(100); // fading speed
f_ct[ch] = 0;
}
else
f_interval[ch] --;
}
else
f_ct[ch] ++;
}
f_wait[ch] --;
}
}
void fading(){
static byte counter = 0;
static boolean prev_off[20];
int i;
for(i = OUT_MIN; i <= OUT_MAX; i++){
if(lumi[i] == 0){
if(prev_off[i] == HIGH){
digitalWrite(i,LOW);
prev_off[i] = LOW;
// delay(1);
}
}
else
lumi[i] --;
}
counter --;
if(counter == 0){
for(i = OUT_MIN ; i <= OUT_MAX; i++){
if(luminance[i]){
digitalWrite(i,HIGH);
prev_off[i] = HIGH;
// delay(30);
}
lumi[i] = luminance[i];
}
}
}
void loop(){
fading();
// delay(10);
}
Thanks for the code
It looks like you are using all the pins so can you drop a schematic in or a picture of the wiring?