Robotics / Mbed 2 deprecated Roboticslab2

Dependencies:   mbed

bluetooth.cpp

Committer:
n6martin
Date:
2014-03-06
Revision:
0:f5f49d8b55da

File content as of revision 0:f5f49d8b55da:

#include <mbed.h>

Serial pc(USBTX, USBRX); // tx, rx
Serial BluetoothSerial(p13, p14);  // tx, rx

char x;

int main() {
BluetoothSerial.baud(9600);
do {
    if (pc.readable()) {
        x=pc.getc();
        // Receive keyboard entry and send to Bluetooth channel
        BluetoothSerial.putc(x); 
        pc.putc(x); //Echo keyboard entry
        }
        if (BluetoothSerial.readable()) {
            x=BluetoothSerial.getc();
            pc.putc(x);
            BluetoothSerial.putc(x);
            }
    }
    while (x!='q');
    }