This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Read data from digital pin on BBC micro:bit board


value = readDigitalPin(microbitObj,pin)



value = readDigitalPin(microbitObj,pin) reads data from the digital pin on the BBC mico:bit board, specified as a microbit object.


collapse all

Create a connection to BBC micro:bit board and read digital pin P5.

microbitObj = microbit('COM3');
dp5 = readDigitalPin(microbitObj,'P5')
dp5 =


Input Arguments

collapse all

BBC micro:bit hardware connection, specified as a microbit object created with the microbit function.

Digital pin number on BBC mico:bit board, specified as a character vector.

Example: 'P5'

Output Arguments

collapse all

Value acquired from the digital pin, returned as a numeric double.

Introduced in R2017b