Working with MATLAB Functions
Use MATLAB® functions to program BBC micro:bit
The Simulink® Coder™ Support Package for BBC micro:bit supports MATLAB functions for BBC micro:bit. These functions enable you to communicate with BBC micro:bit from a host computer running MATLAB. Using MATLAB functions, you can collect data from the sensors on BBC micro:bit and actuate devices attached to BBC micro:bit.
Functions
| microbit | Connect to BBC micro:bit hardware | 
| read | Read data from accelerometer and magnetometer sensors, or read data from an I2C device, connected to BBC micro:bit board | 
| readAcceleration | Read data from the accelerometer sensor on BBC micro:bit board | 
| readMagneticField | Read data from the magnetometer sensor on BBC micro:bit board | 
| writeLED | Write to BBC micro:bit LED | 
| clearLED | Clear the data displayed on the LED on BBC micro:bit | 
| showPins | View an image of BBC micro:bit showing all the pins on the edge connector | 
| configurePin | Configure and display pin modes on BBC micro:bit board | 
| writeDigitalPin | Write to digital pin on BBC micro:bit board | 
| readVoltage | Read analog pin voltage on BBC micro:bit board | 
| readDigitalPin | Read data from digital pin on BBC micro:bit board | 
| writePWMVoltage | Write PWM voltage value on BBC micro:bit board pin | 
| writePWMDutyCycle | Set PWM duty cycle on BBC micro:bit board pin | 
| scanI2CBus | Scan BBC micro:bit board for I2C device addresses | 
| device | Connect to device on I2C or SPI bus on BBC micro:bit board | 
| write | Write data to an I2C device connected to BBC micro:bit board | 
| writeRead | Write and read data from SPI device | 
| readRegister | Read data from I2C device register | 
| writeRegister | Write data to I2C device register | 
Topics
- Glow or Blink LED on BBC micro:bit Using MATLAB FunctionsThis example shows you how to use MATLAB functions to glow or blink an LED on BBC micro:bit 
- Maintain the Orientation of the Image on BBC micro:bit Using MATLAB FunctionsThis example shows you how to use MATLAB functions to maintain the same orientation of an LED image displayed on the BBC micro:bit, even if the board is rotated along an axis