Master Your Micro:bit with Arduino IDE--Button and Other GPIO

In our previous blog Master Your Micro:bit with Arduino IDE ——Light LED, we have talked about how to install micro:bit library on Arduino IDE and how to drive LED on micro:bit with Arduino IDE. In this article, we are going to tell you how to drive micro:bit button and GPIO with Arduino IDE.

Button

Microbit has two self-carried buttons on the board. We call it button A and button B separately. The corresponding IDE PIN for button A is 5 and the corresponding IDE PIN for button B is 11. You can see the circuit diagram for button below.

From this picture, we can see that the button has connected to pull-up resistance. Before the button is pressed, it is in high voltage. After the button is pressed, it is in low voltage. Here's the example code for the button:

Micro:bit leads out partial IO port with its gold finger. We have to pay special attention to that most of IO port can be used repeatedly. To use these IO ports properly, you can refer to conditions of IO port repeat use. For more details, you can see the table below. This table shows various data about each of the pins on the micro:bit edge connector.

You can use aligator clip to lead out P0, P1, P3,3V and GND conveniently. If it is still not enough for you, I would like to recommend you to buy a micro:bit breakout board.

Both the above two breakout boards can lead out all of IO ports, which enable you to program for these IO ports and control the outer circuit.

ELECFREAKS is a globally competitive micro:bit peripheral product manufacturer, working closely with the micro:bit Foundation and its partners. We focus on the development, production and sales of micro:bit extension modules and accessories. In addition to that, the tutorials, blogs, and videos we create are our contribution to building a comprehensive knowledge base for the micro:bit community. Our belief is that programming is more interesting when it is tangible, and we aim to make coding more popular. We promise to provide excellent products and services to our customers.more