• 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: RS485 to CAN Raspberry Pi 5 Audio hat Milk-V Duo Code voice module DeepSeek XiaoZhi AI Voice Chat Robot BOX ESP32-S3 Development Board 1.85 inch Round LCD N16R8 ESP32-P4 Pico Development Board DB C5 MIPI DSI 10.1-inch Display /CSI Camera /Audio Speaker Mic AI Deepseek Serial UART Bus Servo ST3215 30KG.CM/19.5KG.CM Magnetic Encoder 360° High Precision And Large Torque 8.8inch LCD 1920x480 Computer PC Monitor Display Secondary Screen TypeC USB CPU RAM SpotPear Spotpear ESP32-C6 AI 1.54-inch e-Paper Ink Screen 1.54inch Display AIoT Development Board Deepseek WiFi Wireless ESP32 DDSM Motor Driver HAT For Direct Drive Servo Hub Motors For Raspberry Pi X1015 Raspberry Pi 5 PCIe to M.2 Key-M NVMe SSD Board Pi5 2280 Mini TOF Time-of-Flight Laser Ranging Radar Sensor Compatible UART with Arduino Raspberry Pi ESP32 and Pico ESP32 ST7789 Raspberry Pi 5 Argon-NEO-M.2-NVME-PCIE-Expansion-Board Only For Argon NEO 5 Case (Not include) Mini TOF Time-of-Flight Laser Ranging Radar Sensor Compatible with Arduino Raspberry Pi ESP32 and Pico ESP32 P4 Development Board 7-inch LCD Display 1024×600 7inch Touchscreen ESP32-C6 WiFi6 AI Deepseek Mini Uninterruptible Power Supply module Supports charging And Power output at the same time 5V 2.5A RISC-V