Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:2c1acb156d86, committed 2014-03-16
- Comitter:
- zchen78
- Date:
- Sun Mar 16 17:15:41 2014 +0000
- Commit message:
- a helloworld ble demo btw mbed with redbearlab ble chip
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ble_mini.h Sun Mar 16 17:15:41 2014 +0000 @@ -0,0 +1,17 @@ +#ifndef _BLE_MINI_H +#define _BLE_MINI_H +#include "mbed.h" +//Command List +//valid port:1,2,3,4 +#define ON_INTERNEL_LED1 0x01 +#define OFF_INTERNEL_LED1 0x02 +#define ON_INTERNEL_LED2 0x03 +#define OFF_INTERNEL_LED2 0x04 +#define ON_INTERNEL_LED3 0x05 +#define OFF_INTERNEL_LED3 0x06 +#define ON_INTERNEL_LED4 0x07 +#define OFF_INTERNEL_LED4 0x08 + + + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Mar 16 17:15:41 2014 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "ble_mini.h"
+Serial pc(USBTX, USBRX); // tx, rx
+Serial device(p13,p14);
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+
+char buf[10];
+
+int main() {
+ int i=0;
+ //set mbed baud rate the same as BLE mini baud rate
+ device.baud(57600);
+ //simple polling demonstrate serial communication
+ while(1) {
+ if(device.readable()) {
+ buf[i]=device.getc();
+ if(buf[i]==ON_INTERNEL_LED1)myled1=1;
+ if(buf[i]==OFF_INTERNEL_LED1)myled1=0;
+
+ if(buf[i]==ON_INTERNEL_LED2)myled2=1;
+ if(buf[i]==OFF_INTERNEL_LED2)myled2=0;
+
+ if(buf[i]==ON_INTERNEL_LED3)myled3=1;
+ if(buf[i]==OFF_INTERNEL_LED3)myled3=0;
+
+ if(buf[i]==ON_INTERNEL_LED4)myled4=1;
+ if(buf[i]==OFF_INTERNEL_LED4)myled4=0;
+
+
+
+
+
+
+ i++;
+ }
+
+ if(i==10)i=0;
+ wait(0.1);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Mar 16 17:15:41 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file