Created
April 27, 2014 19:12
-
-
Save SaraJo/11353238 to your computer and use it in GitHub Desktop.
Sketch for RFDuino to Blink an LED from an iPhone app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The sketch demonstrates how to do advertise from a Bluetooth Low Energy 4 | |
to the RFduino, then make an LED connected to pin 3 blink. | |
It is supposed to be used with the Cordova RFDuino Plugin Blink app | |
*/ | |
#include <RFduinoBLE.h> | |
int led = 3; | |
void setup() { | |
// led turned on/off from the iPhone app | |
pinMode(led, OUTPUT); | |
// start the BLE stack | |
RFduinoBLE.begin(); | |
} | |
void loop() { | |
} | |
void RFduinoBLE_onDisconnect() | |
{ | |
// don't leave the led on if they disconnect | |
digitalWrite(led, LOW); | |
} | |
void RFduinoBLE_onReceive(char *data, int len) | |
{ | |
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(1000); // wait for a second | |
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment