Contents
Quick Start of MicroBle by MakeCode
A Unity 3D object ‘glasses’ in the Demo scene tilts based on acceleration data provided by the micro:bit. The micro:bit uses its built-in accelerometer to generate 3D Object acceleration ‘x, y, z’ data. The micro:bit sends the acceleration data from the micro:bit to Unity running on a Windows PC via the BLE (Bluetooth low energy) interface.
Additionally, when clicking a Unity 3D object ‘Button’ in the Demo scene, Unity sends the message obtained from a Unity 3D object ‘Inputfield’ to the micro:bit. Unity works on Windows PC and sends a message to the micro:bit using the BLE (Bluetooth low energy) interface.
The following shows a screenshot captured screen while the Demo scene is running.
This Quick Start explains how to display the Demo scene on Unity using this asset. This Quick Start also includes some steps for downloading and setting up a package in Unity project, and writing the micro:bit code.
Step-1 Download and set up a package in Unity Project
Step-2 Write micro:bit code using MakeCode
Step-3 Run Demo scene
Step-1 Download and set up a package in Unity Project
- Download this asset from the Asset Store, and click on the Import button.
- The package is imported under the Assets folder in your Unity project.
- Download the external plugin ’MicroBleConnect_Mc’ below and set it into the ‘Assets/MicroBle_McInterface/Scripts’ folder.
- Click the Project tab, choose ‘Assets’ > ‘MicroBle_McInterface’ > ‘Scenes’ folder of the left side menu, double click on the Demo scene ‘MicroBle_McSampleCode’ in the Project window.
• external plugin ’MicroBleConnect_Mc’
Step-2 Write micro:bit code using MakeCode
- Connect the micro:bit by Micro USB cable to Windows PC, then build a software development environment for this asset with the MakeCode according to ‘MakeCode for micro:bit.’
[ micro:bit Version2.x]
Step-3 Run Demo scene
- In Windows PC, go to ‘Start’, choose ‘Settings’ > ‘Devices’ > ‘Bluetooth and other devices settings’. Click ‘Display other device’ to start searching for the device.
- Like below (Using windows 11), display micro:bit nameed‘BBC micro:bit CMSIS-DAP’.
- Click the ‘Play’ button on Unity. The Unity 3D object ‘glasses’ tilts in sync with the micro:bit when inclining the micro:bit. The ‘Accelx, Accely, Accelz’ in the ‘MicroBle_McSampleCode’ of the ‘Inspector’ tab displays the received acceleration data ‘x, y, z’ from the micro:bit as follows.
- The ’console’ tab displays the game status as follows.
- Display the icon on LED screen after connecting to micro:bit.
- Set the message into Inputfield in the game screen, then click the Button ‘On’ to display the scrolled message in the LED screen of the micro:bit as follows.
- The ’console’ tab displays the game status at clicking Button ‘On’ as follows.