There’s a priceless feeling of pride when you assemble hardware, together with software, creating a masterpiece.

No matter how long you’re tinkering with tech, that feeling never seems to go away.

You’ll want to wire up the 5V relays similar to those shown in the image above.

christmas lights, pi pico, & relays working together

The first (left) terminal does not get used on the 5V Relays.

To dive a bit deeper into electrical automation,check out our relay guidefor details.

Creating the Code

First, slide over to our GitHub repository todownload the code.

relay close up

Let’s review a few important code snippets to understand what’s going on.

Having the ability to importrandom,machine, andtime/sleepfunctionality makes this coding project really simple.

The example code prints the output of(lights); however, this is not required.

christmas light code

On the other hand, you may want to keep it in the code until you’re finished troubleshooting.

For testing purposes, this function was commented out in the example code.

With that said, there is generally more than one way to perform a task.

Review our comparison betweenRPi.GPIO versus GPIO Zerofor details.

Now, the final result.

What’s Your Next Automation Adventure?

Are you ready to automate your house filled with Christmas lights to your favorite rock and roll classics?