🔬
Wiki.Linhkientot
  • 👋Chào mừng tới Linhkientot's Wiki
  • Hướng dẫn phần mềm
    • Cài đặt Arduino IDE 2.0
    • Cài đặt phần mềm Mixly
    • Cài đặt phần mềm Mind+
    • Cài đặt phần mềm Thonny
  • Arduino Products
    • Hướng dẫn ban đầu Arduino IDE
      • Hướng dẫn nạp chương trình Arduino IDE
      • Thêm thư viện Arduino IDE
      • Cài đặt Driver CH340 trên MAC OS
      • Lập trình Board ESP32 trên Arduino IDE
    • Arduino Starter Kit
      • Lesson 0. Getting Started - install IDE
      • Lesson 2. LEDs
      • Lesson 3. RGB LEDs
      • Lesson 4. Eight LEDs and a Shift Register
      • Lesson 5. The Serial Monitor
      • Lesson 6. Digital Inputs
      • Lesson 7. Make an RGB LED Fader
      • Lesson 8. Analog Inputs
      • Lesson 9. Sensing Light
      • Lesson 10 Making Sounds
      • Lesson 11 LCD Displays Part 1
      • Lesson 12 LCD Displays Part 2
      • Lesson 13 DC Motors
      • Lesson 14 Servo Motors
      • Lesson 15 DC Motor Reversing
      • Lesson 16 Stepper Motors
      • Lesson 17 Email Sending Movement Detector
    • Arm Robot
      • Hướng dẫn lắp ráp Arm-4DoF
      • Hướng dẫn lắp ráp Arm-6DoF
      • Hướng dẫn lắp ráp Arm - 6DoF đế tròn quay
    • Car Robot
      • Hướng dẫn lắp ráp tank TS-100
    • Arm Car Robot
    • Smart home IoT
    • Lập trình cảm biến khí ga/ khói MQ-2 Arduino
  • Micro:bit Products
    • Micro:bit Setup
    • Micro:bit Starter Kit V1
      • Setting up the micro:bit with Makecode
      • Set up Arduino IDE for micro:bit
      • Using the Buttons and LED Matrix on micro:bit
      • Pushbutton with micro:bit
      • Tilt Sensor with micro:bit
      • Temperature Sensor with micro:bit
      • DC Motor with micro:bit
      • Sound Sensor with micro:bit
      • Raindrop Sensor with micro:bit
      • Make an RGB LED Blink with micro:bit
      • Ultrasonic Distance Sensor with micro:bit
      • Analog Inputs and micro:bit
      • Servo with micro:bit
      • Smoke sensor with micro:bit
      • Light-dependent Resistor with micro:bit
      • Infrared Obstacle Avoidance Sensor with micro:bit
      • Using LEDs with micro:bit
    • Micro:bit Starter Kit V2
      • Microbit Introduction
      • Microbit Basic Lessons
      • 1. Lesson: Đèn LED nhấp nháy
      • 2. Lesson: RGB Led
      • 3. Lesson: Đọc giá trị từ triết áp
      • 4. Lesson: Đọc nút nhấn
      • 5. Lesson: Servo Motor
      • 6. Lesson: Passive Buzzer-Còi thụ động
      • 7. Lesson: Active Buzzer-Còi chủ động
      • 8. Lesson: Compass-La bàn
      • 9. Lesson: Accelerometer-Gia tốc kế
      • 10. Lesson: Module phát hiện âm thanh
      • 11. Lesson: Cảm biến ánh sáng (quang trở)
      • 12. Lesson: Cảm biến ngọn lửa
      • 13. Lesson: Cảm biến khói
      • 14. Lesson: Cảm biến siêu âm
      • 15. Lesson: ModuleRelay
      • 16. Lesson: Cảm biến nhiệt độ (DHT11)
      • 17. Lesson: Bộ điều khiển từ xa (IR)
      • 18. Lesson: Hiển thị màn hình LCD i2c 1602
      • 19. Lesson: Hiển thị nhiệt độ, độ ẩm trên màn hình LCD
      • 20. Lesson: Điều khiển quạt bằng Relay
    • Micro:bit Advanced Kit V2
      • Giới thiệu BBC Sensor Shield V2
      • Danh sách linh kiện bộ Kit
    • Micro:bit Car
  • ESP32 PRODUCTS
    • Hướng dẫn lập trình ESP32
  • Raspberry Products
    • Raspberry Pico Kit
    • Raspberry Pico Car
  • Group Robots
    • 🤖Arduino Robots
    • 🐦Micro:bit Robots
    • 🍓Raspberry Robots
Powered by GitBook
On this page
  1. Micro:bit Products
  2. Micro:bit Starter Kit V1

Using the Buttons and LED Matrix on micro:bit

PreviousSet up Arduino IDE for micro:bitNextPushbutton with micro:bit

Step 1 The pushbuttons

  • The micro:bit has two on-board momentary pushbuttons, displayed at the front of the board and positioned on either side of the display. They are labelled 'Button A' and 'Button B' and are the primary input devices on the micro:bit.

  • These buttons are unlike the switches you would use to turn on a light. Unlike toggle switches, the pushbuttons on the micro:bit are known as momentary switches. This means it only stays 'on' only as long as it is being pressed. On the other hand, a toggle switch stays 'on' and only goes from 'on' to 'off' when you toggle it again.

Step 2 The LED Matrix Display

  • The micro:bit's LED screen is composed of 25 red LEDs arranged in a 5x5 grid. It is similar to a desktop computer where the monitor may be 1,920 columns of 1,080 pixels. But unlike a desktop monitor, the micro:bit's display has just five columns of five pixels. This is a total of 25 pixels and it's enough to get started with displaying messages, bar graphs or a simple game! Shortly, you will learn to use the display using MakeCode.

  • For more information on the micro:bit and its features, take a look at our guide, 'Meet the micro:bit'.

Step 3 Use the Makecode Editor

  • Click on 'New Project' and you will be directed to the editor

  • For more information on the MakeCode editor, check out our guide, Setting up the Micro:bit with Makecode.

Step 4 Use the 'on button ... pressed' block

  • To start off, let's see how we can use one push button on the micro:bit, specifically Button A. Click on the 'Input' tab and get out a 'on button ... pressed' block.

  • By default, it will be set to button A, so you can leave it as is.

Step 5 Use the 'show icon ...' block

  • Next, click on the 'Basic' tab to get a 'show icon ... ' block

  • Place this block within the 'on button A pressed' block.

  • If you uploaded this code to the micro:bit now and pressed button A, the icon will be displayed on the LED matrix. But first, let's add code for the other button.

Step 6 Use another 'on button ... pressed' block

  • Being able to use one pushbutton is great, but the micro:bit has two pushbuttons. Adding in the second button is as simple as repeating what you’ve already done. So get out another 'on button ... pressed' block.

  • Set it as ' on button B pressed.

  • Grab another 'show icon ... ' block

  • Click on the icon to change it to a different one.

  • Jump to the final step to upload this code to the micro:bit!

Step 7 Display strings with the LED matrix display

  • Click on the 'Basic' tab again, this time getting out a 'show string "Hello!" block.

  • Click on "Hello!" to change the string. Use "Hello World!" instead.

  • Upload this code to the micro:bit as before.

  • You might notice that the "Hello World!" string will display forever while the micro:bit is powered on. Click on the buttons A or B, and the icon will briefly display after "Hello World!"

Step 8 Show string on button press

  • This time, let's get "Hello World!" to display only on button press. There is actually a third option for reading buttons, too. You can read both at the same time. So let's get "Hello World!" to show when buttons A and B are pressed together. Get out another 'on button A pressed' block from the 'Input' tab.

  • Click on 'A' to change it to 'A+B'.

  • Move the 'show string "Hello World!"' block from 'forever' to 'on button A+B pressed'.

Step 9 Using the 'plot x ... y ...' block

  • Another way to use the LED display is by using the 'plot x ... y ... ' block, this comes in handy when displaying graphs. Try it out for yourself, get a "plot x ... y ...' block from the 'Led' tab.

  • Enter the coordinates, 'x 1 y 1' and place it in the 'forever' block

  • Upload this code to the micro:bit.

  • The LED on x:1 y:1 will light up.

Step 10 Change the brightness

  • You can also control the brightness of the LEDs being displayed. To do so, use a 'plot x ... y ... brightness ...' block.

  • To see the difference, use another 'plot x ... y ... brightness' block.

  • Set the first block's brightness to be '255' and the other as '35'.

Step 11 Upload the code to micro:bit

  • To upload the code to the micro:bit, first click the download button in the bottom left corner of the screen.

  • This will download a hex file (computer program file) which the micro:bit can read.

  • Next, plug in your micro:bit, this will reveal a USB on your computer.

  • Copy across the downloaded file to the micro:bit by dragging and dropping it to the MICRO:BIT drive

  • The micro:bit will flash as the code is being uploaded. Once done, unplug the micro:bit.