Rob Toulson / Mbed 2 deprecated PE_12-04_BluetoothMaster

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* Program Example 12.4: Paired Bluetooth master program
00002                                                             */
00003 #include "mbed.h"
00004 Serial rn41(p9,p10);
00005 BusOut led(LED4,LED3,LED2,LED1);
00006 DigitalIn Din(p26);                // digital switch input on pin 14
00007 
00008 char x;
00009 void initialise_connection(void);
00010 
00011 int main() {
00012   rn41.baud(115200);
00013   initialise_connection();
00014   while (1) {
00015     if (Din==1) {            // if digital input switched high   
00016       x=0x0F;              // override with 0x0F
00017     } else {
00018       x++;                 // else increment and
00019       if (x>0x0F) {        // output count value
00020         x=0;
00021       }
00022     }
00023     rn41.putc(x);            // send char data on serial
00024     led = x;                 // set LEDs to count in binary
00025     wait(0.5);
00026   }
00027 }
00028 
00029 // add function initialise_connection code here...
00030