How To Make a Raspberry Pi Pico W Resistor Clock
Decode Resistor Color Codes to Tell the Time
Resistor color codes are an essential part of maker education. The color code system has been in continuous use since the 1930's and was introduced by the Radio Manufacturer's Association as a compact method for marking numerical values on small components. The code contains only 10 colors, but it can still be a challenge to remember their values unless you use them every day.
This project helps you use the resistor code every day to tell the time, and uses a Raspberry Pi Pico W to connect to an NTP (Network Time Protocol) server over Wi-Fi for the current time. Once this is done, the Pico W uses the WS2812B Neopixel strip to display the current time as resistor code colors. By looking at the code in action every day, you will soon be decoding resistor values faster in your sleep!
WS2812B individually addressable RGB LEDs, commonly referred to as "NeoPixels" are super-bright and easily controllable LEDS that can be any color. They are often used to add mood lighting to a project and they can also be used in cosplay costumes and props.
Adafruit's Neopixel Strip needs 5V to drive the LEDs, but can accept a 3.3V logic signal on the data line.
The wiring for the resistor clock is simple, with only GND, Data and Power required to connect the NeoPixel to the Pico W. Connecting the wire so that they fit within the 3D printed case can be a little bit tricky.
1. Begin with the Pi Pico and the Neopixel stick face upwards, with the input end of the NeoPixel near to the USB socket.
2. Connect the wires as shown in the circuit diagram, leaving just enough cable to fold the whole display assembly onto the back of the Raspberry Pi Pico W. The wires will need to be soldered, an easy task for most makers. If you don't have a soldering iron, or fancy an upgrade, take a look at our list of the best soldering irons. Be careful here, because the Neopixel strip has connections on both ends so that they can be chained together. One end of the strip is the input, while the other is the output. You should be soldering wires to the input end.
3. Fold the display assembly onto the back of the Pi Pico W, so that the row of LED lights is aligned with the midline of the Pico.
4. Fix the LED strip in place using a small square of double sided foam tape. The foam enables the NeoPixel strip to sit parallel to the Raspberry Pi Pico W with room underneath to tuck any excess cable.
For most projects, the box you put everything into isn't too important. The Resistor clock is a bit different because we need to do something a little bit crafty to get all of the colors we need. The resistor code is designed for marking with paint, and it uses some colors that are a bit tricky to get by mixing the light from LEDs. Most notably, black, brown, and gray aren't the sort of colors you can get from an LED. Placing a piece of black tinted plastic in front of the LEDs helps here, so that when the LED is off, the plastic will be black, but as soon as the LED is on, you will see the colors. The dark tint will reduce the luminosity of the LEDs, making it easier to differentiate between colors like brown and orange.
1. 3D print the Raspberry Pi Pico case part. You can sand, fill, and finish the outside of the case however you think is best.
2. Insert the Pico-W with the USB socket located in the notch on the case, so that the Pico and NeoPixel fit inside the printed case.
3. Trim two pieces of tinted acrylic to fit the top and bottom of the 3D printed case. If you have access to a laser cutter, you can use this to cut and etch the plastic.
4. Add a drop of superglue to the top (the side where the LEDs are) corners of the 3D printed case, and glue the tinted plastic in place. If you’ve used a Sharpie to color the plastic, put the side with the Sharpie ink towards the inside of the case.
5. Glue the other plastic into place on the rear of the 3D printed case. You can use low temperature hot-glue on this side of the case if you prefer, so that the Pico W can be removed more easily in future.
The Raspberry Pi Pico uses MicroPython to control the Neopixel stick and to connect to NTP servers via a Wi-Fi connection.
1. Follow this guide to download and install the MicroPython firmware to the Raspberry Pi Pico W, and then setup Thonny
2. Create a new file in Thonny and call it wifidetails.py. This file will be used to store the connection details for the wireless network.
3. Add the following lines to the wifidetails.py, replacing the MYSSID and MYPASS with the SSID and password for your wireless network.
4. Save the file to the Raspberry Pi Pico W.
5. Create a new file in Thonny and call it main.py. This is the file that will run when the clock is plugged in. MicroPython is configured to run main.py when the board is powered on.
6. Import the modules that will get you connected to the NTP server, including the login details from the wifidetails.py file that you just created.
7. Import the modules to access the GPIO pins and control the NeoPixels.
8. Create a Python dictionary containing RGB values for each color in the resistor color code. You might need to tweak these values to get the best match from the tinted plastic you are using. A dictionary is a data storage object that uses a key to retrieve a value, in this case we are using a number, 0 to 9, as the key to retrieve the corresponding value.
9. Create an object, np, to tell our code that the NeoPixels are connected to pin 0 on the Raspberry Pi Pico W.
10. Setup and begin the connection to the Wi-Fi network using the ssid and password details from wifidetails.py.
11. Wait for the Wi-Fi network to finish connecting.
12. Check that the network connected successfully, and fail gracefully if there is a problem. If the network connection is good, the IP address of the clock is printed to the Python shell.
13. Get the time from an NTP server using the ntptime module, and reset the Pico W's RTC (real time clock) to match it.
14. Create a loop to read the time from the real time clock and store it in a variable, ct. Then use string formatting to store the time as a 6 digit string we can iterate through to set the NeoPixel RGB values.
15. The timestring variable is now a string with the format "HHMMSS". We iterate through this string to set the RGB values stored in the rc dictionary to the first 6 NeoPixels on the strip, then we write the changes to the NeoPixels. This is the end of the main loop, so we add a delay to ‘tick’ the clock and reduce the load on the Pico W.
16. Save the code to the Raspberry Pi Pico W and click Run to start. The project will get the current time and the NeoPixels will change color to indicate the time. Whenever the Pico is powered up, the code saved in main.py will automatically run.
Join the experts who read Tom's Hardware for the inside track on enthusiast PC tech news — and have for over 25 years. We'll send breaking news and in-depth reviews of CPUs, GPUs, AI, maker hardware and more straight to your inbox.
Andrew is a stay-at-home dad, writer, editor, and professional maker. With a constantly evolving workshop, Andrew makes, modifies, and mends his way through projects with his daughter by his side. Several decades of industry experience and a PhD. from the Ironbridge Institute mean that Andrew's publications cover an eclectic range of topics including ancient Babylonian writing systems to prop-making, accessibility aids, medical devices and well-being, password security, 3D scanning, and 3D printing. Andrew's skill set includes additive and subtractive manufacturing, laser cutting, programming in over 40 years worth of popular languages and frameworks, microprocessors, electro-mechanical devices, marine engines, and a range of manual and CNC machine-shop tools. Based near Ironbridge in England (the birthplace of the industrial revolution), Andrew has a fondness for heritage manufacturing techniques and the aesthetics of the late 19th and early 20th century.
Milk-V Offers a Trio of RISC-V Raspberry Pi Alternatives
Raspberry PI Pico W Copter is Ready for Take Off
SilverStone Sugo SFF Case Supports Quad-Slot GPUs
By Les PounderApril 23, 2023
By Avram PiltchApril 22, 2023
By Brandon HillApril 21, 2023
By Avram PiltchApril 20, 2023
By Brandon HillApril 16, 2023
By Les PounderApril 15, 2023
By Les PounderApril 09, 2023
By Les PounderMarch 25, 2023
By Jarred WaltonMarch 19, 2023
By Les PounderMarch 18, 2023
By Avram PiltchMarch 15, 2023
Begin with the Pi Pico the Neopixel stick face upwards, with the input end of the NeoPixel near to the USB socket. Connect the wires as shown in the circuit diagram, leaving just enough cable to fold the whole display assembly onto the back of the Raspberry Pi Pico W. Fold the display assembly onto the back of the Pi Pico W, so that the row of LED lights is aligned with the midline of the Pico. Fix the LED strip in place using a small square of double sided foam tape. 3D print the Raspberry Pi Pico case part. Insert the Pico-W with the USB socket located in the notch on the case, so that the Pico and NeoPixel fit inside the printed case. Trim two pieces of tinted acrylic to fit the top and bottom of the 3D printed case. Add a drop of superglue to the top (the side where the LEDs are) corners of the 3D printed case, and glue the tinted plastic in place. Glue the other plastic into place on the rear of the 3D printed case. Follow this guide Create a new file in Thonny Add the following lines Save the file to the Raspberry Pi Pico W. Create a new file in Thonny and call it main.py. Import the modules that will get you connected to the NTP server Import the modules to access the GPIO pins and control the NeoPixels. Create a Python dictionary containing RGB values Create an object, np, to tell our code that the NeoPixels are connected to pin 0 on the Raspberry Pi Pico W. Setup and begin the connection to the Wi-Fi network using the ssid and password details from wifidetails.py. Wait for the Wi-Fi network to finish connecting. Check that the network connected successfully, and fail gracefully if there is a problem. Get the time from an NTP server using the ntptime module, and reset the Pico W's RTC (real time clock) to match it. Create a loop to read the time from the real time clock and store it in a variable, ct. Then use string formatting to store the time as a 6 digit string We iterate through this string to set the RGB values stored in the rc dictionary to the first 6 NeoPixels on the strip, then we write the changes to the NeoPixels. Save the code to the Raspberry Pi Pico W and click Run to start.