Writing the Arduino sketch
We will now write the Arduino sketch so that the Arduino board can talk with the BLE module and receive commands from Android via Bluetooth. Here is the complete sketch for this part:
#define LIGHTWEIGHT 1 #include <SPI.h> #include "Adafruit_BLE_UART.h" #include <aREST.h> // Pins #define ADAFRUITBLE_REQ 10 #define ADAFRUITBLE_RDY 2 // This should be an interrupt pin, // on Uno thats #2 or #3 #define ADAFRUITBLE_RST 9 // Create aREST instance aREST rest = aREST(); // BLE instance Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST); void setup(void) { // Start Serial Serial.begin(9600); Serial.println(F("Adafruit Bluefruit Low Energy nRF8001 Print echo demo")); // Start BLE BTLEserial.begin(); // Give name and ID to device rest.set_id("001"); rest.set_name("my_arduino"); } aci_evt_opcode_t laststatus = ACI_EVT_DISCONNECTED; void loop...