MicroBle Quick Start

A Unity 3D object ‘glasses’ in the Demo scene tilts using acceleration data of the micro:bit. The micro:bit generates 3D Object acceleration ‘x, y, z’ data using an accelerometer on the micro:bit. The micro:bit sends the acceleration data from the micro:bit to Unity through Windows PC using the BLE (Bluetooth low energy) interface.

When clicking a Unity 3D object ‘Button’ in the Demo scene, Unity sends position data of the LED screen obtained from a Unity 3D object ‘Inputfield’ to the micro:bit. The micro:bit turns ON/OFF LED screen using it. Unity works at Windows PC and sends the LED screen data to the micro:bit using the BLE (Bluetooth low energy) interface.

The following shows the capture screen when the Demo scene runs.

This Quick Start explains how to display the Demo scene on Unity using MicroBle. 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 Arduino IDE
Step-3 Run Demo scene

Step-1 Download and set up a package in Unity Project

  1. Download MicroBle-v2 from the Asset Store, and click on the Import button.
  2. The package is imported under the Assets folder in your Unity project.
  3. Download the external plugin ’MicroBleConnect-v2’ below and set it into the
    ‘Assets/MicroBleInterface’ folder.
  4. . external plugin ’MicroBleConnect-v2’

  5. Click the Project tab, choose ‘Assets’ > ‘MicroBleInterface’ > ‘Scene’ folder of the left side menu, double click on the Demo scene ‘MicroBleSampleScene’ in the Project window.

Step-2 Write micro:bit code using Arduino IDE

  1. Connect the micro:bit by Micro USB cable to Windows PC, then build a software development environment for MicroBle with the Arduino IDE according to Arduino IDE for MicroBle.
  2. [ micro:bit Version 1.x ( not work 2.x) ]

  3. Compile and write micro:bit code ‘microble-v2.ino’ of the folder ‘/Assets /MicroBleInterface/microble-v2’ into the micro:bit using the Arduino IDE.

Step-3 Run Demo scene

  1. In Windows PC, go to ‘Start’, choose ‘Settings’ > ‘Devices’ > ‘Bluetooth and other devices settings’. Click ‘Add Bluetooth or other device’ to start searching for the device.
  2. Like below, select the Bluetooth device ‘micro:BLE’ you want to add from the list.
  3. 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 Sample Code’ of the ‘Inspector’ tab displays the received acceleration data ‘x, y, z’ from the micro:bit as follows.
  4. The ’console’ tab displays the game status as follows.
  5. The ‘Serial Monitor’ of Arduino IDE displays the acceleration data “x, y, z” as follows.
  6. [ Not connect to Unity ]

    [ Connect to Unity and send acceleration data ]

  7. Set Row / Col of the LED screen into Inputfield ’Row’ / Inputfield ‘Col’ in the game screen, then click the Button ‘On’ to display the indicated LED of the micro:bit. Show correspondence between the Row / Col in the LED screen and Inputfield ’Row’ / Inputfield ‘Col’ as follows.
  8. The ’console’ tab displays the game status at clicking Button ‘On’ as follows.
  9. The ‘Serial Monitor’ in Arduino IDE displays the LED Row/Col data of the LED screen as follows.