Skip to content
Wish Lists Cart
0 items

DIY Bingo Random Number Generator

18 Dec 2023
DIY Bingo Random Number Generator

Wouldn't you like to make your own random number generator for Bingo, one of the indispensable activities of New Year's entertainment? In this project, we are making our own bingo number generator with the Raspberry Pi Kit Picobricks. Don't worry, we have explained how to do it step by step and prepared the necessary Python codes for you.

You're new to coding... You want to test what you have learned. New Year's Eve is approaching. You thought of the bingo game, which is one of the most fun activities on New Year's Eve. You thought to yourself, "I wish I could make my own bingo number generator with the codes I learned." Here we will help you at this stage, future software developer :)

Let's learn how to create a bingo game number generator step by step.

How to Make Random Number Genarator?

Step 1: Let's Gather the Necessary Materials

If you have a Picobricks, you're in luck because all you need is a Picobricks and a printer to print out the bingo cards we've shared with you below. 

In this project we will use the OLED displaybutton and buzzer on PicoBricks. If you want to examine the wiring diagram, here you go:

Step 2: Let's Prepare and Install the Necessary Codes

We have prepared the code for you on 3 different platforms. Choose the one you want and install it on your PicoBricks. If you don't know how to do it, you can check our guide:

How to Use PicoBricks?

BricksIDE Codes

With BricksIDE, our self developed blog based programming IDE, your Bingo number generator will be ready when you prepare a block structure as shown in the image.

Arduino C Codes

#ifndef ACROBOTIC_SSD1306_H
#define ACROBOTIC_SSD1306_H

#if ARDUINO >= 100
 #include "Arduino.h"
 #include "WProgram.h"

#ifdef __AVR__
  #include <avr/pgmspace.h>
  #define OLEDFONT(name) static const uint8_t __attribute__ ((progmem)) name[]
#elif defined(ESP8266)
  #include <pgmspace.h>
  #define OLEDFONT(name) static const uint8_t name[]
  #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
  #define OLEDFONT(name) static const uint8_t name[]

#include "Wire.h"
#include "fonts/font8x8.h"
#include "fonts/font5x7.h"

// Default screen size is 128x64. Using a #define in your sketch before
// the #include statement can change the default size.

#if !defined SSD1306_128_64 && !defined SSD1306_128_32
  #define SSD1306_128_64

#if defined SSD1306_128_64
  #define SSD1306_Max_X                 127
  #define SSD1306_Max_Y                 63
#if defined SSD1306_128_32
  #define SSD1306_Max_X                 127
  #define SSD1306_Max_Y                 31

#define PAGE_MODE                     01
#define HORIZONTAL_MODE               02

#define SSD1306_Address               0x3C
#define SSD1306_Command_Mode          0x80
#define SSD1306_Data_Mode             0x40
#define SSD1306_Display_Off_Cmd       0xAE
#define SSD1306_Display_On_Cmd        0xAF
#define SSD1306_Normal_Display_Cmd    0xA6
#define SSD1306_Inverse_Display_Cmd   0xA7
#define SSD1306_Activate_Scroll_Cmd   0x2F
#define SSD1306_Dectivate_Scroll_Cmd  0x2E
#define SSD1306_Set_Brightness_Cmd    0x81

#define Scroll_Left                   0x00
#define Scroll_Right                  0x01

#define Scroll_2Frames                0x7
#define Scroll_3Frames                0x4
#define Scroll_4Frames                0x5
#define Scroll_5Frames                0x0
#define Scroll_25Frames               0x6
#define Scroll_64Frames               0x1
#define Scroll_128Frames              0x2
#define Scroll_256Frames              0x3

class ACROBOTIC_SSD1306 {
    char addressingMode;
    void init(TwoWire& wire=Wire);

    void setNormalDisplay();
    void setInverseDisplay();

    void sendCommand(unsigned char command);
    void sendData(unsigned char Data);

    void setPageMode();
    void setHorizontalMode();

    void setTextXY(unsigned char Row, unsigned char Column);
    void clearDisplay();
    void setBrightness(unsigned char Brightness);
    bool putChar(unsigned char c);
    void putString(const char *string);
    void putString(String string);
    unsigned char putNumber(long n);
    unsigned char putFloat(float floatNumber,unsigned char decimal);
    unsigned char putFloat(float floatNumber);
    void drawBitmap(unsigned char *bitmaparray,int bytes);

    void setHorizontalScrollProperties(
        bool direction,
        unsigned char startPage,
        unsigned char endPage,
        unsigned char scrollSpeed);
    void activateScroll();
    void deactivateScroll();

    void displayOn();
    void displayOff();

    void setFont(const uint8_t* font, bool inverse=false);

    const uint8_t* m_font;      // Current font.
    uint8_t m_font_offset = 2;  // Font bytes for meta data.
    uint8_t m_font_width;       // Font witdth.
    uint8_t m_col;              // Cursor column.
    uint8_t m_row;              // Cursor row (RAM).
    bool m_inverse=false;       // Inverse text.
    TwoWire* m_wire;

extern ACROBOTIC_SSD1306 oled;  // ACROBOTIC_SSD1306 object


MicroPhyton Codes

from time import sleep
from machine import Pin
from machine import I2C
from picobricks import SSD1306_I2C
import machine
import time

i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=200000)
oled = SSD1306_I2C(128, 64, i2c, addr=0x3c)
pin_button = machine.Pin(10, machine.Pin.IN)
import random

list = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99".split(",")
oled.text("{}".format("Bingo"), 42, 5)
oled.text("{}".format("----------------"), 0, 15)
oled.text("{}".format("Press Button"), 15, 25)
oled.text("{}".format("To Start"), 15, 35)
while True:
    while pin_button.value():
        oled.text("{}".format("Bingo"), 42, 5)
        oled.text("{}".format("----------------"), 0, 15)
        oled.text("{}".format("----------------"), 0, 45)
        random2 = random.randint(0, len(list)-1)
        number = list[random2]
        oled.text("{}".format(number), 52, 30)
Prev Post
Next Post

Thanks for subscribing!

This email has been registered!

Shop the look
Choose Options

Edit Option

Have Questions?

Back In Stock Notification


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