Sending Data from Matrix Keypad to Smartphone using Micro:bit

Micro:bit 28-01-25
23 0

Tutorial plan

1- What is a 4x4 matrix keyboard ?

2- How Micro:bit send data from matrix keypad to Smartphone ?

3- Components Needed

4- Wiring the Components

5- Makecode program for Micro:bit

6- Mobile application with MIT App Inventor

 

 

What is a 4x4 matrix keyboard ?

A 4x4 matrix keyboard is a keypad with 16 keys arranged in four rows and four columns. It is commonly used in embedded systems, microcontroller projects, and digital circuits for input purposes.

How It Works

Instead of connecting each key to a separate input pin (which would require 16 pins for 16 keys), the keys are arranged in a matrix configuration, reducing the number of required pins to 8 (4 rows + 4 columns).

Rows (R1, R2, R3, R4) are connected to output pins.

Columns (C1, C2, C3, C4) are connected to input pins with pull-up resistors.

When a key is pressed, it connects a row to a column, creating a closed circuit.

A microcontroller (e.g., Micro:bit, Arduino, ESP32, Raspberry Pi) scans the rows and detects which column is connected, allowing it to determine which key was pressed.

 

How Micro:bit send data from matrix keypad to Smartphone ?

The Micro:bit reads input from a 4x4 matrix keypad and transmits it to a smartphone using Bluetooth (BLE). The phone receives and displays the data using an app built with MIT App Inventor.

1- User presses a key on the 4x4 matrix keypad.

2- Micro:bit scans the keypad and detects the pressed key.

3- Micro:bit transmits the key value via Bluetooth (BLE).

4- A smartphone receives the data through an MIT App Inventor application.

5- The app displays the pressed key on the screen.

 

Components Needed

Micro:bit Board

Micro:bit board

The Micro:bit is the microcontroller that handles all the logic and control of the system. It reads input from the 4x4 matrix keyboard, processes the input, and sends the relevant output to the SSD1360 display or other connected devices.

The GPIO expansion card for the Micro:bit card

The GPIO expansion card for the Micro:bit card

The GPIO expansion board for the Micro:bit board expands the capabilities of the Micro:bit board by adding more input/output (GPIO) pins and additional functionality.

4x4 Matrix Keyboard

The 4x4 matrix keyboard acts as the input device. It allows the user to press keys to send commands or data to the Micro:bit. This is typically used for entering PINs, controlling devices, or interacting with the system.

Jumper Wires

Jumper wires

Jumper wires are used to physically connect the Micro:bit board, the 4x4 matrix keyboard, and the SSD1360 display. These wires transfer electrical signals between the components, allowing them to communicate.

Breadboard:

Breadboard

A breadboard can be used to create a temporary circuit for testing and prototyping.

 

Wiring the Components

4x4 Matrix Keypad to Micro:bit:

We connect the 8 outputs of the keypad to the 8 pins of the Micro:bit card following this order: P0, P1, P2, P3, P4, P5, P6 and P7.

 

Programming Micro:bit with Makecode

1- Go to Microsoft MakeCode and start a new project.

2- In MakeCode, open the Blocks Editor (https://makecode.microbit.org/).

3- Insert the Makecode blocks that allow you to :

Set up the keypad: Define rows as outputs and columns as inputs.

Scan the keypad: Loop through rows, set one HIGH at a time, and check which column is LOW.

Send data over Bluetooth: When a key is pressed, send its value using the bluetooth uart write string function.

Download prpgram

 

Mobile application with MIT App Inventor

To receive the keypad data via Bluetooth, we create an Android app using MIT App Inventor.

Steps to Create the App

1. Go to MIT App Inventor.

2. Create a new project.

3. Add the Bluetooth Client component (BluetoothLE).

4. Add UI components:

- Label (to display received key data).

- ListPicker (to select the Micro:bit's Bluetooth).

- Button (to connect/disconnect Bluetooth).

 

MIT App Inventor Blocks

1- Starting with Android 12, Bluetooth permissions have been enhanced to improve security and user data protection. This is why we must declare the authorizations that your application needs in the AndroidManifest.xml file. For Bluetooth, you'll need to include ACCESS_FINE_LOCATION, BLUETOOTH_SCAN, and possibly BLUETOOTH_CONNECT permissions, depending on the features you're using.

2- Use these programming blocks to connect the smartphone to the Micro:bit board via Bluetooth:

3-Use the blocks to continuously read incoming UART data from Micro:bit and display its in the phone :

Download project Download application

Connecting the Micro:bit to the Smartphone

1- Power on the Micro:bit and ensure Bluetooth is enabled.

2- Open the MIT App Inventor app on your phone.

3- Click Scan & Connect to find your Micro:bit.

4- Select the Micro:bit and click Connect.

5- When you press a key on the 4x4 keypad, it should appear on your phone.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info