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.
Dependencies: BLE_API mbed nRF51822
Revision 2:fc105f4c854e, committed 2015-09-26
- Comitter:
- roywant
- Date:
- Sat Sep 26 00:08:25 2015 +0000
- Parent:
- 1:03c191369089
- Child:
- 3:bfd6f56605d7
- Commit message:
- Example Switch/Led Code for Eddystone Seed Beacon
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BLE_API.lib Sat Sep 26 00:08:25 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#c4436674db7b
--- a/main.cpp Sun Jan 01 20:57:57 2012 +0000
+++ b/main.cpp Sat Sep 26 00:08:25 2015 +0000
@@ -1,12 +1,58 @@
#include "mbed.h"
+#include "BLEDevice.h"
+#include "DeviceInformationService.h"
+
+
+InterruptIn button1(P0_17);
+InterruptIn mysw1(P0_18);
+DigitalOut myled1(P0_12);
+DigitalOut myled2(P0_15);
+DigitalOut myled3(P0_16);
+// Serial pc(USBTX,USBRX);
+int count = 0;
+int flag = false;
-DigitalOut myled(LED1);
+// Callback for button1
+void handle_sensor() {
+ count++;
+ myled2 = !myled2;
+}
+
+void handle_sw1() {
+ flag = !flag;
+ }
+
+
+void ledflasher() {
+ myled1 = 1;
+ wait(0.3);
+ myled1 = 0;
+ myled2 = 1;
+ wait(0.3);
+ myled2 = 0;
+ myled3 = 1;
+ wait(0.4);
+ myled3 = 0;
+ }
int main() {
+ // Initialize button1 and pull up
+ // set interrupt callback for button1
+ button1.fall(&handle_sensor);
+ mysw1.fall(&handle_sw1);
+ button1.mode(PullUp);
+ mysw1.mode(PullUp);
+ myled1 = 0;
+ myled2 = 0;
+ myled3 = 0;
+
while(1) {
- myled = 1;
- wait(0.2);
- myled = 0;
+ if (flag) {
+ ledflasher();
+ }
wait(0.2);
}
+
+
+
}
--- a/mbed.bld Sun Jan 01 20:57:57 2012 +0000 +++ b/mbed.bld Sat Sep 26 00:08:25 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nRF51822.lib Sat Sep 26 00:08:25 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#d0fc349b9a1b