First working board
Tap a button and update a display
Use the bundled Hello World board when you want the fastest proof that the app, BLE module, and Arduino sketch are talking.
Checklist
-
Install the Arduino library
Install Bluetooth Serial Connect from Library Manager, or add the ZIP from this repo.
-
Wire the BLE module
Cross TX/RX, share GND, and power the module at the voltage printed on its board or datasheet.
-
Open the Hello World template
In the app, go to Templates -> Examples -> Hello World. It uses Button 0 and Text Display 0.
-
Upload the sketch
Use the example below. If your board has no
Serial1, use theNo_Serial1orSoftware_Serialexample instead. -
Connect and tap
Connect to the BLE module from a physical iPhone or iPad, then tap Button 0. The app should show the press count.
Hello World sketch
#include <BluetoothSerialConnect.h>
BluetoothSerialConnect serialConnect(Serial1, true);
int pressCount = 0;
void setup() {
Serial.begin(9600);
serialConnect.begin(9600);
Serial.println("Setup complete");
}
void loop() {
serialConnect.readSerial();
// Button B0 was just pressed.
if (serialConnect.wasButtonPressed(0)) {
pressCount++;
serialConnect.sendAlert("Hello from the Arduino!");
serialConnect.setDisplay(String("Presses: ") + pressCount, 0);
}
// Text typed in the app console.
if (serialConnect.hasMessage()) {
serialConnect.setDisplay(serialConnect.getMessage(), 0);
}
}