İçeriğe Geç

Projeler

#2 Action Reaction Project With micro:bit

Tarafından PicoBricks Team 18 Apr 2025

As Newton explained in his laws of motion, a reaction occurs against every action. Electronic systems receive commands from users and perform their tasks. Usually a keypad, touch screen or a button is used for this job. Electronic devices respond verbally, in writing or visually to inform the user that their task is over and what is going on during the task. In addition to informing the user of these reactions, it can help to understand where the fault may be in a possible malfunction.

Buttons are circuit components through which we can provide input. Different types of buttons are used in electronic systems: toggle switches, push buttons and more. PicoBricks has a total of 3 push buttons, with 1 on the potentiometer and button module and 2 on the Micro:Bit. Push buttons function similarly to switches; they conduct current when pressed and do not conduct when released. PicoBricks has a total of 3 push buttons, with 1 push button on the potentiometer and button module, and 2 push buttons on the Micro:Bit. Push buttons operate like switches. Push buttons transmit current when pressed and do not transmit when released.

In the project, when the button on the potentiometer & button module is pressed, we will make the smiley face emoji we created on the Micro:Bit LED matrix blink.

Connection Diagram:

You can prepare this project without making any wiring connections.

Project Images:


MakeCode Code of The Project:

If you have completed the PicoBricks - MakeCode connection and add-on installation steps, the coding steps to follow for the first project are detailed in the visual below. 


Python Code of The Project:

#Action-Reaction Project
from microbit import *
from picobricks import *

# Pin Initialization
Button_Pin = pin2

# Function Initialization
oled = SSD1306()
oled.init()
oled.clear()
oled.add_text(0,0,"Hello World")

#smile images
pb_smile = [
    [1, 1, 0, 1, 1],
    [1, 1, 0, 1, 1],
    [0, 0, 0, 0, 0],
    [1, 0, 0, 0, 1],
    [0, 1, 1, 1, 0],
]
#blink images
pb_blink = [
    [1, 1, 0, 0, 0],
    [1, 1, 0, 1, 1],
    [0, 0, 0, 0, 0],
    [1, 0, 0, 0, 1],
    [0, 1, 1, 1, 0],
]

while True:
    button = Button_Pin.read_digital()
    if button == 1:
        for y in range(5):
            for x in range(5):
                if pb_blink[y][x] == 1:
                    display.set_pixel(x, y, 9)
                else:
                    display.set_pixel(x, y, 0)
    else:
        for y in range(5):
            for x in range(5):
                if pb_smile[y][x] == 1:
                    display.set_pixel(x, y, 9)
                else:
                    display.set_pixel(x, y, 0)

MicroBlocks Code of The Project:

Önceki Gönderi
Sıradaki Gönderi

Abone olduğun için teşekkürler!

Bu e-posta kaydedildi!

Görünümü satın alın
Seçenekleri Seçin

Seçeneği Düzenle

Stok Bildirimi

Karşılaştır

Ürün Stok KoduDeğerlendirmeAçıklama Kategori Uygunluk Ürün Tipi Diğer Detaylar
this is just a warning
Giriş Yap
Alışveriş Sepeti
0 Ürünler
Same Day Shipping No Extra Costs
Easy Returns Guarantee Return with Ease
Secure Checkout Secure Payment