• 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 27W Power Mobile Robot Electronic EYE 0.71 inch Round Double LCD Display Dual Screen For Arduino Raspberry Pi ESP32 Pico STM32 User Guide 4 inch e Paper HAT+ E Ink Spectra E6 Full-Color 600x400 Screen Display For Arduino /Raspberry Pi /Jetson Nano /STM32 Raspberry Pi Pico 10.1inch DVI LCD LuckFox Pico Raspberry Pi Camera Module 3 Sensor Assembly IMX708 Official Original 11.9MP Camera ESP32-S3 Industrial-Grade WiFi Relay IOT RS485 Communicator Bluetooth Raspberry Pi Pico 2 RP2350 ETH CH9120 TCP/UDP Ethernet Network For Arduino Raspberry Pi Pico 2 RP2350 CAN Onboard XL2515 CAN Controller RP2350A Industrial Modbus POE ETH RJ45 To Relay 30CH RTU/Modbus TCP-Ethernet For IOT Servo PWM motor WP5320 WP5335 35/20KG.CM 180° PWM digital servo double ball bearings ESP32-S3 Round Screen Raspberry Pi Pico 2 RP2350 1.8 inch AMOLED Development Board Display 368×448 TouchScreen Programmable Watch QSPI Raspberry Pi Pico rp2040 Display image 1.3inch LCD ST7789 change bmp to hex and Audio Speaker Raspberry Pi 5 5V5A Industrial Isolated RS485 TO ETH (C) RJ45 Converter Wall/Rail-Mount For Modbus D-Robotics RDK X3 Development Board Horizon Sunrise Pi ARM Cortex-A53 5Tops 2GB/4GB RAM