• sales

    +86-0755-88291180

Chapter 2 of KitiBot-Microbit: Keys User Guide

Keys

There are two keys on Micro:bit, A and B. In this Chapter, we are using them.


Keys programming we need to use the block "on button .. pressed". With the block, the micro:bit could detect if key A is pressed or if A and B keys are pressed at the same time. If the key is pressed, the scripts in this block will run.


According to Chapter 1, let's learn how to program keys. We try to create a project that LED matrix display A, B and C separately when key A, B, A and B are pressed.


First, create new project. Find block "on button A pressed" in Input class and drag it to the right. Add one string display block. Copy the button and string blocks change for B key and AB keys operation.

Download the code to micro:bit for testing. You can also check the effect according to left simulate area.

Buttons could also be controlled by another block. Different with the last one, the block we used before run the included program when buttons are pressed. This block will return a value "true" if buttons are pressed, otherwise return value "false"


We create a new project and rewrite it with this block. In this project, we need to use if-else block. If it get ture, the blocks included will run, otherwise the blocks in else will run.


Add blocks that display string when buttons are pressed. You can simulate the effect on the left area


If you are much careful, you will find that the project first detect if A and B are pressed at the same time, then detect if A and B is pressed separately. You can try to change the order to test what will happen if the order is changed

TAG: Raspberry Pi 5 Raspberry Pi 5 inch DSI MIPI Display LCD (D) Capacitive TouchScreen 720x1280 HDMI to TTL Mini TV ESP32 C3 ST7789 Pi5 Fan Raspberry Pi Compute Module 5 PoE BASE A IO Board RJ45 For CM5 Lite/eMMC PoE-M.2-HAT+B User Guide Raspberry Pi 5 PCIe to USB Gen1 HUB and M.2 NVMe SSD PI5 Expansion board HAT+ Raspberry Pi 5 Arduino MEGA2560 R3 ISX031C GMSL Camera H100 Image Sensor IP67 protection rating For Jetson Orin And MAX9296 GMSL camera ESP32 S3 Development Board 1.5 inch Round Rotary OLED TouchScreen Smart Knob Display 1.5inch Display 466x466 LVGL for Arduino EchoEar ESP32 S3 AI Development Board with 1.85-inch LCD Display Cute Cat Pet Chatting Robot N32R16 ESP32-S3 Raspberry Pi 5 CR2032 Raspberry Pi 5 Camera User Guide Raspberry Pi Pico 2 RP2350-Matrix Development Board 8×8 RGB LED Matrix QMI8658 6-Axis Sensor Raspberry Pi CM5 Gigabit/2.5G Dual Ethernet Expansion Board with RJ45 GPIO IO Base Raspberry Pi 5 RTC Box