Dear Arduino Community,
I am currently working on an art installation that utilises 16 led strips (LinearZ 52 toshiba ssc led strip Zhaga Sunlike). These run off 4 led drivers (Meanwel LCM-60 230v)- 1 driver for four strips. The drivers have a pwm modulation option and so I am using a single arduino nano (chinese clone) to modulate all of them with 1pwm pin each.
the idea is to create a compostion for the lights that fades them in and out, leaves them at different opacities, strobes,... basicaly creates various light intensities that change over fixed period of time. I imagine this to be a 20 minute loop.
i tryied various ways of going around this but it only worked partially (which is confusing) or not at all (which is also confusing:). First I attempted nested seqence of if / else if / else if / else if / ... but it only seems to work for first few elses and than it doesnt (which i dont get). than i tried creating various functions (i hope this is the right term?) that would be called from outside the void loop () to make the code more concise, but to no vail.
and now im just stuck ![]()
I am attaching the code i came up with this far, together with picture of the hardware for wiing for illustration.
I can confirm that arduino can control the leds' fading (but for some reason cant bring it all the way down to turn it off, which is nevertheless a minor issue now) but i cant get it to do the sequence correctly.
can anyone please suggest a solution?
thank you very much!
code for my if - else if - else if aproach that worked at the beggining but didnt when i added more time sequenceses
#define strip1 3
#define strip2 5
#define strip3 6
#define strip4 9
int brightness = 0; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
unsigned long currentTime;
void setup() {
pinMode (strip1,OUTPUT);
pinMode (strip2,OUTPUT);
pinMode (strip3,OUTPUT);
pinMode (strip4,OUTPUT);
Serial.begin(9600);
}
void loop() {
currentTime = millis();
analogWrite(strip1, brightness);
analogWrite(strip2, brightness);
analogWrite(strip3, brightness);
analogWrite(strip4, brightness);
if (currentTime >= 0 && currentTime <=15000) { // fades leds in and out for 150seconds
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(10);
}
else if (currentTime > 15000 && currentTime <=30000) { // fades leds in and out FASTER for another 150sec
int fadeAmount2 = fadeAmount*4;
brightness = brightness + fadeAmount2;
if (brightness <= 0 || brightness >= 250) {
fadeAmount2 = -fadeAmount2;
}
}
else if (currentTime > 30000 && currentTime <=45000) { // same as above, stays at maximum brightness. i didnt continue further
int fadeAmount2 = fadeAmount*4;
brightness = brightness + fadeAmount2;
}
Serial.println (currentTime);
}
code for the functions approach
#define strip1 3
#define strip2 5
#define strip3 6
#define strip4 9
unsigned long currentTime;
int output;
int brightness = 0;
//int fadeAmount = 5;
void setup() {
pinMode (strip1,OUTPUT);
pinMode (strip2,OUTPUT);
pinMode (strip3,OUTPUT);
pinMode (strip4,OUTPUT);
Serial.begin(9600);
}
int time1 () { //function 1
int fadeAmount = 1;
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
delay (50);
}
return brightness;
}
int time2 () { // function 2
int fadeAmount = 5;
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
delay (10);
}
return brightness;
}
void loop() {
currentTime = millis();
if (currentTime >= 0 && currentTime <= 10000) { //call function 1
output = time1;
}
if (currentTime > 10000 && currentTime <= 20000) { //call function 2
output = time2;
}
Serial.println (currentTime);
analogWrite (strip1, output);
analogWrite (strip2, output);
analogWrite (strip3, output);
analogWrite (strip4, output);
}
thanks for any comments to my approaches or even to suggesting a completely dufferent appraoch.
im all ears ![]()

