Bluetooth LED Triggering using FRDM-K64F

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
architmuchhal
Date:
Mon Dec 05 20:33:13 2016 +0000
Commit message:
FRDM-K64F based LED Trigerring

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 05 20:33:13 2016 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+#include <stdio.h>
+#include <string.h>
+
+Serial pc(USBTX, USBRX);
+
+DigitalOut GREEN (LED2); //FRDM in-built LED
+DigitalOut led (PTC17);  //External LED from breadboard
+
+Serial blue(PTC15, PTC14); //HC-06 TX and RX
+
+int c = 0;
+
+int main ()
+{
+    GREEN = 1; //FRDM LED initially OFF
+    led = 0;   //External LED initially OFF
+    while(1)
+    {
+        if(blue.readable()> 0)
+        {
+            c = blue.getc(); 
+            } 
+            if (c == '1') 
+            {
+                //LEDs in OFF State
+                
+                GREEN = 1;
+                led = 0;
+                }
+                else if (c == '2') 
+                {
+                    //LEDs in ON State
+                    
+                    GREEN = 0;
+                    led = 1;
+                    blue.printf("LED: ON");
+                    }
+                }
+            }
+    
+    
+    
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 05 20:33:13 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file