The second article of operating App Inventor of BLE with Arduino 101 is here! This series of articles describe how to use App Inventor of BLE (Bluetooth Low Energy) to interact with the Arduino 101 development board in various ways. You must import BLE component(.aix) as an extension before using it. A screenshot of the actual app execution is shown below.
Arduino 101 is the latest development board under cooperation between Arduino.cc (NOT .org) and Intel, also known as Genuino 101 outside of the USA.
Basically, this example is almost identical with [App Inventor and Arduino: Lesson 1: LED Blink], except we use BLE component in this case. In this example we will use the slider to control the brightness of Arduino 101 D9 LED.
Here a Slider that is used to control the brightness of the LED, along with Clock components that regularly send the position of the slider pointer to Arduino 101 through BLE components. The position of the slider pointer is also displayed in the TextBox. You cannot use the original BluetoothClient components to communicate with Arduino because of the difference in the communication protocol.
1. Initialize and connect
In the Initializing window use BluetoothLE1 to scan for available devices, which will detect if your Arduino 101 is ready.
Next, click the ConnectButton and in the ConnectButton.Click window choose BluetoothLE1 to connect to the specified device. Type in your Arduino 101 bluetooth address here (98:4F…). Please modify the address string according to your Arduino 101.
2. Connection confirmed
BluetoothLE1.connected window will be called after the connection is established, as shown below.
3. Continuous Transmission Signal
Use the Clock.Timer command to accomplish the following two tasks with a time interval of 100 (every 0.1 second)
· Display the position of the pointer of the slider in the TextBox.
· Use BluetoothLE1.WriteIntValue command to send out the pointer position, then with this information Arduino 101 will control the brightness of the LED via the analogWrite command. Type in “19B10011-E8F2-537E-4F6C-D104768A1214″ in both service_uuid and characteristic_uuid columns. Arduino 101 uses this parameter as its BLE service.
When you press the Button_Disconnect button (Button_Disconnect.Click window), BluetoothLE1 component will disconnect with the specified device (Arduino 101).
Arduino 101 Code
Copy the code and paste it onto Arduino 101. Please notice that Arduino 101 has onboard BLE hardware, therefore you don’t need to connect other Bluetooth modules such as HC05.
service_uuid and characteristic_uuid are also specified in the sketch as “19B10011-E8F2-537E-4F6C-D104768A1214″, which must be the same with the string you use in App Inventor.