In the previous article, we discussed How to DIY a PVC Pipe Lamp. Since the switch wasn’t done properly and the button travel was too large, if you can't resolve this issue, you can follow along with this guide to create a portable lamp controlled by a microcontroller.
First, cut a piece of copper-clad board.
Solder on five high-brightness LEDs.
The order from left to right is: white, red, white, green, white.
For the LED board, the LEDs share a common positive terminal, and the main control board manages the negative terminal. So, you'll need to drill five holes to solder the control wires to the back.
Here's another example. This uses an STC8G1K08 microcontroller for the main control board. It has a tactile switch to turn the lamp on and off and to switch between light modes.
For the casing, the PVC pipe is heated and flattened. The circuit board edges are glued to make a square shape, then holes are drilled to make it look much better.
The button cap is made by gluing a small piece of PVC board onto a screw, then installing it on a hand-turned lathe for a great tactile feel and nice feedback.
Press and hold the button for 3 seconds to turn it on. Each press will cycle through the following modes:
· Red light: fast blink, slow blink, steady
· Green light: fast blink, slow blink, steady
· White light: fast blink, slow blink, steady
Press and hold the button again for 3 seconds, and the red and green lights will flash once to turn off. The lamp will remember the last light mode used before turning off.
Weight: 30g, with a 480mA lithium battery.
A strong magnet allows you to attach the lamp to a belt buckle for night use.
Close-up of the LEDs: each has a 3W power rating, providing sufficient brightness with a large light angle due to the lens.