-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from davidperrenoud/master
Added Remote LED example
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*************************************************************************************** | ||
* | ||
* Title: Remote LED | ||
* Description: Turn the on-board LED on and off by Bluetooth. | ||
* Tip: After upload, select the Bluetooth port with Tools > Port and send 1 | ||
* or 0 with the Serial Monitor. Don't forget to select the USB port back | ||
* before uploading. | ||
* | ||
***************************************************************************************/ | ||
#include <prismino.h> | ||
#include <Bluetooth.h> | ||
|
||
void setup() | ||
{ | ||
// open Bluetooth communication and wait for port to open | ||
delay(1000); | ||
Bluetooth.begin(9600); | ||
delay(1000); | ||
|
||
// set pin output mode (sources current) | ||
pinMode(LED, OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
if(Bluetooth.available()) | ||
{ | ||
// read value received by Bluetooth | ||
char val = Bluetooth.read(); | ||
|
||
switch (val) | ||
{ | ||
case '1': | ||
// turn LED on | ||
digitalWrite(LED, HIGH); | ||
break; | ||
case '0': | ||
// turn LED off | ||
digitalWrite(LED, LOW); | ||
break; | ||
} | ||
} | ||
delay(1); | ||
} |