Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsA scoreboard is a good first project in reading buttons. This one uses two push buttons with the Pico's internal pull-up resistors, so no extra parts are needed. The program debounces each press, adds a point to the right player and shows both scores in large digits. Holding both buttons for a second resets the score. Good for table tennis, carrom or a quiz at home.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power bank.
main.pyimport time
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
a = Pin(14, Pin.IN, Pin.PULL_UP)
b = Pin(15, Pin.IN, Pin.PULL_UP)
score = [0, 0]
prev = [1, 1]
both_since = None
def draw():
oled.fill(0)
oled.text("Player A", 0, 0)
oled.text("Player B", 72, 0)
oled.text(str(score[0]), 16, 28, 1)
oled.text(str(score[1]), 88, 28, 1)
oled.show()
draw()
while True:
now = (a.value(), b.value())
for i in (0, 1):
if prev[i] == 1 and now[i] == 0:
score[i] += 1
draw()
prev[i] = now[i]
if now == (0, 0):
if both_since is None:
both_since = time.ticks_ms()
elif time.ticks_diff(time.ticks_ms(), both_since) > 1000:
score = [0, 0]
both_since = None
draw()
else:
both_since = None
time.sleep_ms(30)
The 30 ms loop delay debounces most buttons. Raise it slightly if needed.
A both-pressed hold gives each player a point before the reset. Change the code to ignore that if you like.
Check I2C wiring and the driver install.
Yes. Scale text with a small bitmap-font helper or use a larger display.
Yes. Add the buzzer on another pin and beep on a point.
Add another button and extend the score list.
5 parts: Raspberry Pi Pico, 2 × Tactile Push Button Switch, 0.96" OLED Display 128x64, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 45 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (main.py).
About ₹619 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Using internal pull-up resistors; Debouncing with timestamps; Detecting a two-button hold.
Ideas that reuse this build: Pico stopwatch lap OLED. They are listed under Take it further on this page.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Learning project. Check every circuit and the datasheet of each part before you power it up.