– Select one of the paired devices, in my case the HC-06. – Click the BT button to bring up a list of paired devices. The first time the app is run there is no saved address and the app waits for the user to make a connection. By saving the address every time a new connection is made the user can change Bluetooth modules with ease. Then, when the the app is run again it can use the saved address to auto-connect to the Bluetooth module. This makes it very difficult to use a different Bluetooth module.Ī better way is to allow the user to connect to any BT module and then save the address for next time. This is quick and easy but it means the mac address for the BT module is hard coded in to the app and to change the address you would need to change the app and recompile.
Since the Screen1.Initialize block runs automatically when the app is started, the app would try to make the connection every time it started. The easiest way to add an auto connect would be to use a fixed address and put the connection function call in the Screen1.Initialize block. See Turning a LED on and off with an Arduino, a HC-06 and AndroidĪ few people have asked how to make it so that the app auto-connect to the Arduino on start up and I thought I would offer my solution. In a previous post I showed how to connect an app inventor Android app to a Bluetooth module connected to an Arduino to control an LED.