Skip to content

Projects

#9 Fizz-Buzz Game With micro:bit

by PicoBricks Team 06 May 2025

There are some games that every programmer spends time on. Fizz Buzz is one of them. Every programmer who has made some progress in a programming language has created the algorithm for the Fizz-Buzz game, aiming to master that language by writing this game. The Fizz-Buzz game is frequently preferred in programming language education because its algorithm includes both conditional statements and loop structures, helping to grasp the steps of computational thinking. At the same time, while playing this game, we improve our quick decision-making and mathematical thinking skills.

Thanks to PicoBricks, we can code this game by using electronic components and experience it physically.

In this project, we will create the Fizz-Buzz game algorithm and code using PicoBricks along with the button, RGB LED, and OLED screen module with Micro:Bit. The Fizz-Buzz game is played by counting numbers from 1 to 100. Starting from 1, when a number that is a multiple of 3 is reached, "Fizz" is said. When a number that is a multiple of 5 is reached, "Buzz" is said. When a number is a multiple of both 3 and 5, "Fizz-Buzz" is said instead of the number.

Connection Diagram:

You can prepare this project without making any cable connections.


Project Images:

 

MakeCode Code of The Project


Python Code of The Project:

#Fizz-Buzz Game Projects
from microbit import *
from picobricks import *
import neopixel
import music

# Pin Initialization
Button_Pin = pin2
RGB_Pin = pin8
Num_Leds = 3

# Function Initialization
oled = SSD1306()
oled.init()
oled.clear()
np = neopixel.NeoPixel(RGB_Pin, Num_Leds)

button = Button_Pin.read_digital()
display.show(Image.HEART)

oled.add_text(2,0,"Press the")
oled.add_text(1,1,"A Button to")
oled.add_text(3,2,"start")
oled.add_text(2,3,"Fizz-Buzz")

def left_image():
    display.show(Image('00900:'
                       '09000:'
                       '99999:'
                       '09000:'
                       '00900'))
#Neopixel
np[0] = (0, 0, 0)
np[1] = (0, 0, 0)
np[2] = (0, 0, 0)
np.show()

while True:
    if button_a.is_pressed():
        oled.clear()
        counter=1
        left_image()
        while counter<100:
            oled.add_text(0,0,"Press the PB")
            oled.add_text(3,1,"Button")
            oled.add_text(5,2,str(counter))
            button = Button_Pin.read_digital()
            if button==1:
                counter=counter+1
                music.play(['b'])
                oled.add_text(3,3,"         ")
                np[0] = (0, 0, 0)
                np[1] = (0, 0, 0)
                np[2] = (0, 0, 0)
                np.show()
            if counter % 3 == 0:
                oled.add_text(3,3,"Fizz")
                np[0] = (255, 0, 0)
                np[1] = (255, 0, 0)
                np[2] = (255, 0, 0)
                np.show()
            if counter % 5 == 0:
                oled.add_text(3,3,"Buzz")
                np[0] = (0, 0, 255)
                np[1] = (0, 0, 255)
                np[2] = (0, 0, 255)
                np.show()
            if counter % 15 == 0:
                oled.add_text(3,3,"Fizz-Buzz")
                np[0] = (128, 0, 128)
                np[1] = (128, 0, 128)
                np[2] = (128, 0, 128)
                np.show()

MicroBlocks Code of The Project

 

Prev Post
Next Post

Thanks for subscribing!

This email has been registered!

Shop the look
Choose Options

Edit Option

Back In Stock Notification

Compare

Product SKURatingDescription Collection Availability Product Type Other Details
this is just a warning
Login
Shopping Cart
0 items
Same Day Shipping No Extra Costs
Easy Returns Guarantee Return with Ease
Secure Checkout Secure Payment