October 26, 2018
10.25.2018 – Bluetooth Module with Unity via MSP430 + HC-05
Posted by cfitzsim under UncategorizedNo Comments
Although we will use the controllers that ship with Daydream or Vive, we still may want to implement a separate, large button that can stop the game at any time and alert a staff member to help the student take off their equipment. That button could be attached with Velcro to the swivel chair the student sits in. This sort of button could prove helpful if a student is overwhelmed by the game, or simply wants to stop playing for some reason. It could help prevent a student from trying to take off the equipment themselves, preventing the risk of them hurting themselves or dropping equipment.
To start creating this button, we used the following:
- MSP430 launchpad w/ button
- Used MSP430 UART sketch for reference
- HC-05 Bluetooth module
- Ardity (Unity Asset)
- Android & Microcontrollers / Bluetooth (Unity Asset)
We will still need:
- A bigger button. Some bigger buttons are built for arcade use and require 12V power supply (way too much).
- External power supply for MSP430 to make it completely wireless
The HC-05 Bluetooth module uses the MSP430 UART interface. The module itself connects to a computer through a COM port. When the module is connected to a computer for the first time, you need to pair the device by entering its password (1234). You can tell which port(s) the module uses by right clicking on it.
The MSP430 code is similar to a sketch done by TI (msp430fr69xx_euscia0_uart_04.c) . I simply load data into the TX buffer when one of the on-board buttons are pressed. That triggers an interrupt which transmits the data through the COM port. For the purposes of testing the module, I also wrote that if we send a lowercase ‘h’ to the module, the red on board LED will illuminate.
Then, a terminal program (such as RealTerm or Termite) is used to check that the code is actually working (i.e. you send something and receive from MSP430). I then used Ardity to read from the COM port associated with the module into Unity.
After I determined that the module was working and my code was good, I moved to using this on Android. As before, I downloaded a Bluetooth Terminal App on the Android and confirmed I could send and receive information.
After I did that, I downloaded a Unity asset made for reading Bluetooth module output into an Android. I set it up and confirmed I was able to read data from a button press into our Unity Android game. The downside of this is that the Google Daydream Previewer will not receive data through the Android—it needs to use a COM port from the computer on which Unity is running. However, I am happy that I was able to read a button push into our Unity proof of concept and bring up a “Pause” screen.
Leave a Reply