by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Committer:
robt
Date:
Sun Jun 16 15:30:01 2013 +0000
Revision:
0:d008cfe824aa
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:d008cfe824aa 1 /* Program Example 12.4: Paired Bluetooth master program
robt 0:d008cfe824aa 2 */
robt 0:d008cfe824aa 3 #include "mbed.h"
robt 0:d008cfe824aa 4 Serial rn41(p9,p10);
robt 0:d008cfe824aa 5 BusOut led(LED4,LED3,LED2,LED1);
robt 0:d008cfe824aa 6 DigitalIn Din(p26); // digital switch input on pin 14
robt 0:d008cfe824aa 7
robt 0:d008cfe824aa 8 char x;
robt 0:d008cfe824aa 9 void initialise_connection(void);
robt 0:d008cfe824aa 10
robt 0:d008cfe824aa 11 int main() {
robt 0:d008cfe824aa 12 rn41.baud(115200);
robt 0:d008cfe824aa 13 initialise_connection();
robt 0:d008cfe824aa 14 while (1) {
robt 0:d008cfe824aa 15 if (Din==1) { // if digital input switched high
robt 0:d008cfe824aa 16 x=0x0F; // override with 0x0F
robt 0:d008cfe824aa 17 } else {
robt 0:d008cfe824aa 18 x++; // else increment and
robt 0:d008cfe824aa 19 if (x>0x0F) { // output count value
robt 0:d008cfe824aa 20 x=0;
robt 0:d008cfe824aa 21 }
robt 0:d008cfe824aa 22 }
robt 0:d008cfe824aa 23 rn41.putc(x); // send char data on serial
robt 0:d008cfe824aa 24 led = x; // set LEDs to count in binary
robt 0:d008cfe824aa 25 wait(0.5);
robt 0:d008cfe824aa 26 }
robt 0:d008cfe824aa 27 }
robt 0:d008cfe824aa 28
robt 0:d008cfe824aa 29 // add function initialise_connection code here...
robt 0:d008cfe824aa 30