I'm very new to Arduino. I just received the Arduino 101 and successfully made an Android controlled project (via CurieBLE) that changes RGB LED color remotely.
I'm trying to integrate a rechargeable battery. I was about to buy one of these solutions:
Hi Julien,
unfortunately, even though the Curie chip contains a battery charger, its pins are not exported to any header so you can't use them directly
This sketch is placed in examples,under CurieBLE,
For reference , giving the sketch here
/*
Copyright (c) 2015 Intel Corporation. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <CurieBle.h>
BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're programming)
BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service
// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
const int ledPin = 13; // pin to use for the LED
void setup() {
Serial.begin(9600);
// set LED pin to output mode
pinMode(ledPin, OUTPUT);
// set advertised local name and service UUID:
blePeripheral.setLocalName("LED");
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:
blePeripheral.begin();
Serial.println("BLE LED Peripheral");
}
void loop() {
// listen for BLE peripherals to connect:
BLECentral central = blePeripheral.central();
// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());
// 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()) {
if (switchCharacteristic.value()) { // any value other than 0
Serial.println("LED on");
digitalWrite(ledPin, HIGH); // will turn the LED on
} else { // a 0 value
Serial.println(F("LED off"));
digitalWrite(ledPin, LOW); // will turn the LED off
}
}
}
// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}
Thanks for your reply. I still do not understand what to do. When I load this sketch I get a "connected to central" message on my monitor and apps will connect to the LED. I do not get any of the text strings from the sketch to show on the terminal.the terminal, not even from setup(). Cant make the LED blink. What do I do now. I am completely lost.
You need to have companion app to test - On Windows PC, I had installed New bit BLE Tool.
On android phone, install BLE scanner app.
Then, you can see Characteristic, and send values.
Some apps send Hex.. Check the app details how to set hex.
Attaching a screenshot of Newbit tool, see the right end, where one can send values.
As per program, anything other than zero makes the LED HIGH , zero makes 13 pin to LOW.