#13 Table Lamp With micro:bit
Many of us, for reasons such as studying, reading books, preparing reports, etc., prefer to illuminate only our desks instead of turning on all the lights in the room at night. The desk lamps we use at home typically use RGB LEDs as light sources. This is because RGB LEDs can emit light in desired color tones. Exposure to certain lights for extended periods can negatively impact our eye health. In such cases, quick transitions between desired colors can be achieved using the color values of RGB LEDs, ranging from 0 to 255. Additionally, RGB LEDs can operate without requiring large power sources. Therefore, desk lamps can be easily illuminated with their own power sources.
In this project, we will add various features to a table lamp in our home by using PicoBricks modules.
(You can use any table lamp in your home.)
We will illuminate a desk lamp by using PicoBricks RGB LED and Gesture modules based on the directional movements we make with our hands. After placing the Gesture and RGB LED modules, when we move our hand to the left over the gesture module, the RGB LEDs illuminate according to the color counter. After moving our hand up or down over the gesture module, when we move our hand to the right again, the color of the RGB LED changes. To turn off the desk lamp, you can move your hand to the right over the gesture module.
Connection Diagram:
You can prepare this project by breaking PicoBricks modules at proper points.

Project Images:
![]() |
![]() |
![]() |
![]() |
MakeCode Code of The Project
Python Code of The Project:
#Table Lamp Project
from microbit import *
from picobricks import *
import neopixel
# Pin Initialization
RGB_Pin = pin8
Num_Leds = 3 #Enter the number of LEDs
# Function Initialization
apds = APDS9960()
apds.init_gesture_sensor()
np = neopixel.NeoPixel(RGB_Pin, Num_Leds)
#Neopixel
np[0] = (0, 0, 0)
np[1] = (0, 0, 0)
np[2] = (0, 0, 0)
np.show()
colorCounter=0
display.show(Image.HAPPY)
r=[255,128,188,62,139,255,18]
g=[255,135,0,177,50,60,168]
b=[255,193,0,136,0,0,168]
while True:
gesture = apds.read_gesture()
if gesture=="RIGHT":
np[0] = (r[colorCounter], g[colorCounter], b[colorCounter])
np[1] = (r[colorCounter], g[colorCounter], b[colorCounter])
np[2] = (r[colorCounter], g[colorCounter], b[colorCounter])
np.show()
display.show(Image.HEART)
elif gesture=="LEFT":
display.show(colorCounter)
np[0] = (0, 0, 0)
np[1] = (0, 0, 0)
np[2] = (0, 0, 0)
np.show()
elif gesture=="UP":
colorCounter=colorCounter-1
if colorCounter<0:
colorCounter=6
display.show(colorCounter)
elif gesture=="DOWN":
colorCounter=colorCounter+1
if colorCounter>6:
colorCounter=0
display.show(colorCounter)
MicroBlocks Code of The Project