Bluetooth LED Triggering using FRDM-K64F

Dependencies:   mbed

main.cpp

Committer:
architmuchhal
Date:
2016-12-05
Revision:
0:938c4afdc9b9

File content as of revision 0:938c4afdc9b9:

#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");
                    }
                }
            }