Christmas light driver pack

Morning,
I’m after suggestions for how to drive lots of sets of cheap christmas lights using either a Pi or Arduino, with what I’ve been reading so far it seems like using the PC to control some h bridges sounds like the way to go, Ideally I’m after something fairly basic that fits in a normal xmas lighting enclosure with the PSU and is easy enough to control… wifi would be a bonus

the lights generally have two configurations, 4-36v DC (allowing for Dimming) or 4-36v A/C and needing up to a 240hz signal to stop flickering (those cheap two wire sets) the ability to control rgb in future would be nice, even better if my single 24v/30v 100w PSU could power the whole thing, each light set uses maybe 15-30w max and I’d love to have some sort of short protection on the outputs. each box has up to 6 x sets of lights coming out of it, ability for more is handy etc

2 Likes

Morning Michael,

Very interesting project, yes some L298 should be capable of handling the current for sets of lights such as that, but always be sure to double-check and leave some margin for peaks. As for dimming, I’d recommend using an Arduino so that you can easily combine it with some PWM which will let you dim the lights while maintaining voltage (this is important as cheap LED usually have a pretty sharp drop off, so you won’t get a linear gradient change fading down, but more of a fast drop in brightness, which is actually a trick taken advantage of by some lights to appear as rain) as for protection, you won’t need much more than an inline fuse, as even the slow blow usually tend not to damage the LED when below the appropriate threshold.

Have a great day Michael!

Bryce
Core Electronics | Support

2 Likes

Sounds good, which Arduino do I need, is there some easy software I can use to program the Arduino (a nice Gui would be handy) so it automatically goes back to it’s last setting (I like the lights just constant on) I assume the Uno R3 would handle plenty of the H Bridges?

anyone attempted to use an Arduino to run a light show that’ll need long cables to communcate between modules (say 10-20m) suggestions for an easy timing software?

2 Likes

Hey Michael,

The Arduino IDE is a text editor rather than a GUI, but there’s plenty of tutorials you can find online for writing the scripts to create functions and contain them in a loop in order to perform your control in the project. If you find that the Arduino Uno doesn’t have the number of pins and PWM pins that you require you can switch it out to a Mega, but personally, with small scripts as a beginner I wouldn’t say that it’s necessary. If there’s anything else that we can do for you please let us know.

Bryce
Core Electronics | Support

2 Likes

I have a cousin that knows the Pi pretty well (he says) the wifi it has would also be a benefit to have access to see it’s status and adjust etc

would this sort of thing work?

1 Like

it does look like a huge amount of boards to have, I’d rather just the Arduino and stacks of L298’s…

I’d really love to have wifi access to show the status of that box… do any of the L298’s give feedback to the Arduino or Pi about how they are operating/if there is a load etc?

Hi Michael,

On the same thread as using a motor driver to provide power, I would check out this Pi HAT:

The L298 does have feedback through a current sensing resistor:

I’m not too sure how you would go about controlling a large amount of LED’s with the motor driver.

PS: I would also have a look at controlling them using a transistor such as the TIP120

Let us know how you go!

Cheers,
Liam.

1 Like

Hmmm, maybe the Mega with the ethernet hat would satisfy the remote access questions, then I just need the L298N’s

is there software I can run under windows to easily control/get a status dashboard for all the L298N’s ?

the DMX512 hat is an awesome thing for the future

Blockquote
tutorials you can find online for writing the scripts to create functions and contain them in a loop in order to perform your control in the project
Blockquote

are you able to suggest something for a starter, I’ve seen plenty of code talking about flipping the outputs a certain direction, but not necessarily something offering flipping at a certain timeframe and the ability to adjust the duty cycle at the same time?

Hi Michael,

To confirm, are you looking to switch from a certain set of outputs and adjust your duty cycle periodically? How long is the period? Depending on the system you’ve already got in place in order to control the lights, it may be as simple as creating a script that stores an array (basically just a list of values) that then updates itself in a certain way at a given point in time (we can likely use either an RTC or simple functions on the board in order to maintain the timing) which would be running a function to control your lights based on the drivers interface.

Bryce
Core Electronics | Support

2 Likes

I’d like to cycle at around 120 or 240hz

the light strings are set so they basically use a A/C signal, the positive part of the wave (if you will) energises half the string and the negative (or reversed polarity) drives the other, so to drive both sides at once it needs a high frequency signal(so there is no flickering)

so i’d like the ability to try a few frequencies (maybe 120/360/720hz?)
the next is to control the dimming which just needs the duty cycle to be controlled (cutting short the length of the frequency) which I’d like to be slightly diffferent to controlling the output voltage… some sets need 24v, other up to 34v.

happy to paypal some $$ for your time to whip something up that’s easy to control

1 Like

Hey Michael,

Unfortunately, Core Electronics doesn’t offer a service to design a script or control system. That being said, your best bet is to check out Fiverr or another freelance based company to create it for you (Engineering groups at Universities are a great spot to check-in with too). As for the cycle, I was referring to the timing of your diming (if it’s autonomous) and how often it would need to be triggered rather than the frequency of the current that the lights are to operate at. Also, what’s the exact voltage and current you’d be using, we’ll need to make sure that all the connections and parts won’t be overloaded before you set it up.

Bryce
Core Electronics | Support

2 Likes

Soo, I’ve more or less accomplished making this work…here’s my code:
/*
A very basic program to use a L298n Motor controller to power two wire christmas light sets
the light sets are designed to use each side of a A/C wave form to drive half of the lights
so if you replace the controller they come with you need 120hz or more for flicker free

This Version for the Jaycar L298n 

*/

int motor1dir1 = 22;
int motor1dir2 = 24;
int motor1speed = 2;

int motor2dir1 = 26;
int motor2dir2 = 28;
int motor2speed = 3;

void setup() {
//setup code for pins

pinMode(motor1dir1, OUTPUT);
pinMode(motor1dir2, OUTPUT);
pinMode(motor1speed, OUTPUT);
pinMode(motor2dir1, OUTPUT);
pinMode(motor2dir2, OUTPUT);
pinMode(motor2speed, OUTPUT);

}

void loop() {
// the loop function runs over and over again forever:

digitalWrite(motor1dir1, HIGH);
digitalWrite(motor1dir2, LOW);
analogWrite(motor1speed, 255);
digitalWrite(motor2dir1, HIGH);
digitalWrite(motor2dir2, LOW);
analogWrite(motor2speed, 255);
delay(5);

digitalWrite(motor1dir1, LOW);
digitalWrite(motor1dir2, HIGH);
digitalWrite(motor2dir1, LOW);
digitalWrite(motor2dir2, HIGH);
delay(5);

}

as you can see it just tells the driver to switch direction with a 5ms delay…

from here I need a huge heatsink if I’m to drive a half decent load as it’s running the thing a pretty much max capacity, so with even just a few strings it’s getting hot, I’m also going to need to figure out how to setup current display. anyway it works!

pin outs from a geuine mega:

2 and 3 PWM are to the motor speed control as they are the only pins that need PWM, the other four (in the case of this L298n) are 22/24/26/28 digital for motor direction control (does the flip flopping)

2 Likes

and this for another controller … “DF Robot” from Core-Electronics a while back

/*
A very basic program to use a L298n Motor controller to power two wire christmas light sets
the light sets are designed to use each side of a A/C wave form to drive half of the lights
so if you replace the controller they come with you need 120hz or more for flicker free

This Version using the L298n from DFRobot.

*/

int motor1pin1 = 2;
int motor1pin2 = 3;

int motor2pin1 = 4;
int motor2pin2 = 5;

void setup() {
//setup code for pins

pinMode(motor1pin1, OUTPUT);
pinMode(motor1pin2, OUTPUT);
pinMode(motor2pin1, OUTPUT);
pinMode(motor2pin2, OUTPUT);
}

void loop() {
// the loop function runs over and over again forever:

digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);

digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
delay(1);

digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, HIGH);
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, HIGH);
delay(1);

}

1 Like