LED Bluetooth Control Using NRF Connect
by TechMartian in Circuits > Arduino
5220 Views, 15 Favorites, 0 Comments
LED Bluetooth Control Using NRF Connect
![Wwo8JLbBR02dyHe83z+feA_thumb_3c5.jpg](/proxy/?url=https://content.instructables.com/F93/885T/J5Y7ZVRM/F93885TJ5Y7ZVRM.jpg&filename=Wwo8JLbBR02dyHe83z+feA_thumb_3c5.jpg)
![adyAMZP3QUyuFh38zaeOlQ_thumb_3bf.jpg](/proxy/?url=https://content.instructables.com/F3R/Z60X/J5Y7ZWGH/F3RZ60XJ5Y7ZWGH.jpg&filename=adyAMZP3QUyuFh38zaeOlQ_thumb_3bf.jpg)
![M8qnSvCYTUyLIKKNqVgDXw_thumb_3c3.jpg](/proxy/?url=https://content.instructables.com/FO9/DR06/J5Y7ZW68/FO9DR06J5Y7ZW68.jpg&filename=M8qnSvCYTUyLIKKNqVgDXw_thumb_3c3.jpg)
This is the last module on the Arduino 101 Essentials series and marks the beginning of a new Arduino 101 BLE uses series.
This is an introduction on how to use the Bluetooth Low Energy capabilities of the Arduino 101 to control an LED remotely over BLE4.1. Furthermore, this uses an app that is very versatile and flexible for developers and is only compatible with the Arduino 101, called nRF Connect, which is quite different from it's other bluetooth counterparts like Blink. This can be applied to a number of other applications, from reading bluetooth unlocked.
The fact that the Arduino 101 possesses Bluetooth Low Energy (BLE4.1) is what makes it unique and different from all the other Arduino boards. It allows us to connect with our circuits remotely over bluetooth, even from another room!
BoM
![NoXeLWH1SlytcNha8JPRpA_thumb_3c4.jpg](/proxy/?url=https://content.instructables.com/FI4/NTRV/J5Y7ZVRV/FI4NTRVJ5Y7ZVRV.jpg&filename=NoXeLWH1SlytcNha8JPRpA_thumb_3c4.jpg)
![ecg+TS3YTdaKjnJLwbwFfA_thumb_3be.jpg](/proxy/?url=https://content.instructables.com/FH0/QD0M/J5Y7ZWFJ/FH0QD0MJ5Y7ZWFJ.jpg&filename=ecg+TS3YTdaKjnJLwbwFfA_thumb_3be.jpg)
- Arduino 101 (or any bluetooth capable Arduino boards)
- LED
- 100Ω resistor
- Jumper Wire
- Breadboard
Wiring
![Screen Shot 2017-08-06 at 1.19.56 PM.png](/proxy/?url=https://content.instructables.com/FF1/0X6Q/J5Y7YNUN/FF10X6QJ5Y7YNUN.png&filename=Screen Shot 2017-08-06 at 1.19.56 PM.png)
![LED Circuit](/proxy/?url=https://content.instructables.com/FR7/23G2/J5Y7YLOB/FR723G2J5Y7YLOB.jpg&filename=LED Circuit)
![kO+b54UnS4S568HDaS+wuQ_thumb_3c0.jpg](/proxy/?url=https://content.instructables.com/FRX/V5XB/J5Y7ZWEL/FRXV5XBJ5Y7ZWEL.jpg&filename=kO+b54UnS4S568HDaS+wuQ_thumb_3c0.jpg)
![iWVvfB7pSsihcQvFeVBWKA_thumb_3c1.jpg](/proxy/?url=https://content.instructables.com/FCG/EWBT/J5Y7ZWF2/FCGEWBTJ5Y7ZWF2.jpg&filename=iWVvfB7pSsihcQvFeVBWKA_thumb_3c1.jpg)
- Connect the anode (positive pin) of the LED to a 100Ω resistor.
- Then, connect this 100Ω resistor in series to pin 9 on the Arduino.
- Connect the cathode (negative pin) of the LED to the ground pin of the Arduino 101 labeled as GND.
Coding
![Screen Shot 2017-08-06 at 1.18.57 PM.png](/proxy/?url=https://content.instructables.com/FTS/6TM0/J5Y7YNJK/FTS6TM0J5Y7YNJK.png&filename=Screen Shot 2017-08-06 at 1.18.57 PM.png)
The code is vastly different and more complex than any simple blinking an LED demo, since it needs to activate the bluetooth and interface properly. You can also change the name of your board under the command,
blePeripheral.setLocalName("Tech Martian");
This is the name that will show up in the App itself, so name it uniquely.
#include <CurieBLE>h>
BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're programming) BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service
//set BLE characteristic BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
const int ledPin = 9; // pin to use for the LED
void setup() { // set LED pin to output mode pinMode(ledPin, OUTPUT);
// set advertised local name and service UUID: blePeripheral.setLocalName("Tech Martian"); blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
// add service and characteristic: blePeripheral.addAttribute(ledService); blePeripheral.addAttribute(switchCharacteristic);
// set the initial value for the characeristic: switchCharacteristic.setValue(0);
// begin advertising BLE service: digitalWrite (ledPin, HIGH); blePeripheral.begin(); }
void loop() { // listen for BLE peripherals to connect: BLECentral central = blePeripheral.central();
// if a central is connected to peripheral: if (central) { // while the central is still connected to peripheral: while (central.connected()) { // if the remote device wrote to the characteristic, // use the value to control the LED: if (switchCharacteristic.written()) { // any value other than 0, turn on the LED if (switchCharacteristic.value()) { digitalWrite(ledPin, HIGH); } //else turn the LED off else { digitalWrite(ledPin, LOW); } } } } }
Downloads
Using the NRF Connect
![Screen Shot 2017-08-06 at 1.20.17 PM.png](/proxy/?url=https://content.instructables.com/F61/D6PN/J5Y7YNU6/F61D6PNJ5Y7YNU6.png&filename=Screen Shot 2017-08-06 at 1.20.17 PM.png)
![Screen Shot 2017-08-06 at 1.20.25 PM.png](/proxy/?url=https://content.instructables.com/FCY/4EIQ/J5Y7YNTJ/FCY4EIQJ5Y7YNTJ.png&filename=Screen Shot 2017-08-06 at 1.20.25 PM.png)
![Screen Shot 2017-08-06 at 1.20.33 PM.png](/proxy/?url=https://content.instructables.com/FBT/ETEV/J5Y7YNT5/FBTETEVJ5Y7YNT5.png&filename=Screen Shot 2017-08-06 at 1.20.33 PM.png)
![zOfpmwWnR0mca+Z9CElRKA_thumb_3c2.jpg](/proxy/?url=https://content.instructables.com/FAD/B9TY/J5Y7ZVKN/FADB9TYJ5Y7ZVKN.jpg&filename=zOfpmwWnR0mca+Z9CElRKA_thumb_3c2.jpg)
- Connect with your device, mine is called "Tech Martian," but yours may change.
- Under Unknown Service >> Unknown Characteristic, press the upload button.
- Choose Uint 8 on the drop down box and type 0 for OFF and 1 for ON
Done
![LED Bluetooth Control](/proxy/?url=https://content.instructables.com/FMT/PKCV/J5Y7YLRX/FMTPKCVJ5Y7YLRX.jpg&filename=LED Bluetooth Control)
Play with the LED by setting different values on the app! This is just the beginnings of what you can do with bluetooth control. More is coming, stay tuned makers!