O'Reilly logo

Arduino Android Blueprints by Stefan Buttigieg, Marco Schwartz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing the Arduino sketch

Now that we know that our sensors are working correctly, we can write the final sketch that allows the Arduino board to be accessed by the Android application we will write later on. The following is the complete sketch for this part:

// Control Arduino board from BLE // Enable lightweight #define LIGHTWEIGHT 1 // Libraries #include <SPI.h> #include "Adafruit_BLE_UART.h" #include <aREST.h> #include "DHT.h" // Pins #define ADAFRUITBLE_REQ 10 #define ADAFRUITBLE_RDY 2 #define ADAFRUITBLE_RST 9 // DHT sensor #define DHTPIN 7 #define DHTTYPE DHT11 // DHT instance DHT dht(DHTPIN, DHTTYPE); // Create aREST instance aREST rest = aREST(); // BLE instance Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required