• 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 Camera NVIDIA Jetson Orin Nano/NX PoE Mini Expansion Board Power over Ethernet RJ45 802.3af compliant Raspberry Pi Game RS422 to CAN Power Manager Module Raspberry Pi 4.26 inch e-Paper link (G) RYBW 800x480 For Arduino / Jetson / STM32 /ESP32 4 inch e Paper HAT+ E Ink Spectra E6 Full-Color 600x400 Screen Display For Arduino /Raspberry Pi /Jetson Nano /STM32 Raspberry Pi CM5 IO BASE B Mini Board a Base Development Platform Compute Module 5 IO Board with EEPROM And Encryption chip JETSON NANO MINI ESP32 RV1106 Raspberry Pi 5 UPS HAT E 4-Port For 21700-Li-Battery (NOT includ) 5V6A Uninterruptible Power Supply 1.85inch LCD TouchScreen Display 360×360 ST77916 For Arduino /Raspberry Pi /ESP32 /Pico /STM32 Raspberry Pi Pico 2 W RP2350 Pico2W ARM Cortex-M33 And RISC-V Hazard3 Wi-Fi4 Bluetooth5.2 CYW43439 Raspberry Pi 8 inch DSI LCD Display With 5MP Front Camera MIPI 800×480 Capacitive TouchScreen Raspberry Pi 5 POE PCIe To M.2 E KEY NGFF WIFI7 WIFI6 For BE200/AX210/AX200/RTL8822CE Raspberry Pi 5 Case ESP32 1.5inch LCD Raspberry Pi 3.5 inch LCD G Display Resistive TouchScreen 60fps ST7796 320x480 Also For Arduino/Pico2/ESP32/RP2040/RP2350 Raspberry Pi 5 Silver-Shadow Case