Bluetooth avanzado

Dependencies:   mbed

main.cpp

Committer:
gerardo_carmona
Date:
2014-09-23
Revision:
0:1a819403fbb3

File content as of revision 0:1a819403fbb3:

/* 
    -- TV_bluetooth-Rx-simple --
    Example using a Bluetooth module. In this case
    we use the HC-06 model.
    
    Pairing code: 1234
    Baud rate: 9600
    
    

*/


#include "mbed.h"

DigitalOut myled(LED_GREEN);
Serial pc(USBTX, USBRX);
Serial bt(PTE0, PTE1);


int main(){
    int i = 0;
    pc.printf("Hello World!\n");
    myled = 1;
    
    while (true) {
        wait(0.5f); // wait a small period of time
        pc.printf("%d \n", i); // print the value of variable i
        bt.printf("%d \n", i); // print the value of variable i
        i++; // increment the variable
        
        if (bt.readable()){
            char c = bt.getc();
            if (c == 'H' || c == 'h'){
                myled = 0;
            }else if (c == 'L' || 'l'){
                myled = 1;
            }
        }
    }
}