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 analog pin voltage on BBC micro:bit board


voltage = readVoltage(microbitObj,pin)



voltage = readVoltage(microbitObj,pin) reads the voltage on the analog input pin on the BBC mico:bit board, specified as a microbit object.


collapse all

Create a BBC micro:bit object and read voltage from an analog pin.

microbitObj = microbit('COM3');
vp10 = readVoltage(microbitObj,'P10')
vp10 =


Input Arguments

collapse all

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

Analog pin number on the BBC micro:bit board, specified as a character vector.

Example: 'P0'

Output Arguments

collapse all

Voltage read from the analog pin on BBC micro:bit board, specified as a numeric double.

Introduced in R2017b