• 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: Tuya AI Voice Robot T5-E1 1.75 inch Round AMOLED TouchScreen GPS For XiaoZhi Development Board Core3566102032 Raspberry Pi screen Industrial ESP32-S3 Relay 8-Channel 8-Ch ESP32-WROOM IOT WiFi Bluetooth HAT For Arduino ESP32 S3 Development Board 1.46 inch Round LCD 1.46inch Display 412x412 QMI8658 Sensor / MIC / SD /MP3 Audio /Battery Port LVGL/HMI For Arduino ESP32 C5 Development Board 1.47 inch LCD Display Screen ST7789 For WiFi6/LVGL/HMI Onborad SD-Port/RGB-LED Raspberry Pi CM5 IO BASE A Mini Board a Base Development Platform Compute Module 5 IO Board Arducam CSI-to-HDMI Industrial UART To WiFi Raspberry Pi AF Camera Jetson Nano 4G module Raspberry Pi 5 IMX477 IR CUT Camera (A) 12.3MP For Jetson Nano/Orin And Raspberry Pi Allwinner H618 3.5 inch LCD Computer CPU GPU RAM Monitor PC USB Secondary Display Screen Rounded LCD ESP32-P4 DEV-KIT C6 WiFi6 MIPI DSI 7/10.1 inch Display/CSI Camera/Audio Speaker For AI Deepseek SIM8260G M2 3G/4G/5G/GNSS/GPS Sub-6G PCIe M.2 Moudle For LTE-A/NSA/SA For DFOTA /VoLTE For SIMCOM Raspberry Pi 5 PCIe to USB Gen1 HUB and M.2 NVMe SSD PI5 Expansion board HAT+ Desktop Ornament