Ternary RGB LED Clock With RP2040-Matrix and MicroPython
by arduinocelentano in Circuits > Clocks
111 Views, 0 Favorites, 0 Comments
Ternary RGB LED Clock With RP2040-Matrix and MicroPython


Have you ever marveled at the simplicity of a binary LED clock? It’s a fascinating concept where time is represented using just two states: on and off. But what if we could take that idea and elevate it to a whole new level? Introducing the 🌈Ternary RGB LED Clock⏰, where three colors are used to represent ternary digits!
💡I intentionally kept the project as simple as possible so that you can use it in Computer Science or STEM classes to playfully introduce the concepts of numeric systems and the basics of interfacing with the LED matrix. The MicroPython code is about 50 lines long.
🔗 You might also like another RP2040-Matrix project I published here.
Supplies

- RP2040-Matrix development board (alternatively, you may use any generic RP-2040 board with an external NeoPixel LED matrix)
- Thonny IDE to program it
The Concept

We'll use red, green, and blue pixels to represent the numbers 0, 1, and 2. The embedded matrix allows us to display five columns, enabling us to show the month, day, hours, minutes, and seconds. In the attached picture, you can see the layout. If you are not familiar with the ternary numeric system, there is an example of calculations provided.
The RP2040 features an embedded real-time clock. However, it does not have internet connectivity, so the time must be set manually.
Installing Thonny IDE

Now that we've covered how it works, we're ready to get started!
Visit thonny.org to download Thonny. Simply follow the installation instructions for your operating system.
Installing MicroPython (Optionally)

If you haven't used your board with MicroPython before, you'll need to install it. To do this, press and hold the BOOT button on your RP2040-Matrix board before connecting it to your computer.
Once it's plugged in, release the BOOT button and open Thonny. Navigate to the 'Tools → Options' menu. In the 'Interpreter' tab, select the appropriate port and click on the 'Install or update MicroPython' link.
Uploading the Code

Unplug your board and then plug it back in. Create a new file and paste the provided MicroPython code. Press the ▶️ 'Run' button and enjoy the animation!
💡 If the onboard files do not appear in the 'Files' tab, try pressing the 🛑 'Stop' button.
💡 To have the code start automatically, make sure to name the file main.py.