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
Fork of EddystoneBeaconSwitchLed by
Revision 3:2340e6920afe, committed 2015-09-29
- Comitter:
- scottjenson
- Date:
- Tue Sep 29 00:22:55 2015 +0000
- Parent:
- 2:fc105f4c854e
- Commit message:
- Update for tinyBLE
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r fc105f4c854e -r 2340e6920afe main.cpp
--- a/main.cpp Sat Sep 26 00:08:25 2015 +0000
+++ b/main.cpp Tue Sep 29 00:22:55 2015 +0000
@@ -2,49 +2,42 @@
#include "BLEDevice.h"
#include "DeviceInformationService.h"
+int ledOn = 0;
+int ledOff = 1;
InterruptIn button1(P0_17);
InterruptIn mysw1(P0_18);
-DigitalOut myled1(P0_12);
-DigitalOut myled2(P0_15);
-DigitalOut myled3(P0_16);
+DigitalOut myled1(P0_21);
+DigitalOut myled2(P0_22);
+DigitalOut myled3(P0_23);
// Serial pc(USBTX,USBRX);
-int count = 0;
int flag = false;
-// Callback for button1
-void handle_sensor() {
- count++;
- myled2 = !myled2;
-}
-
-void handle_sw1() {
+void handle_button1() {
flag = !flag;
}
void ledflasher() {
- myled1 = 1;
+ myled1 = ledOn;
wait(0.3);
- myled1 = 0;
- myled2 = 1;
+ myled1 = ledOff;
+ myled2 = ledOn;
wait(0.3);
- myled2 = 0;
- myled3 = 1;
+ myled2 = ledOff;
+ myled3 = ledOn;
wait(0.4);
- myled3 = 0;
+ myled3 = ledOff;
}
int main() {
// Initialize button1 and pull up
// set interrupt callback for button1
- button1.fall(&handle_sensor);
- mysw1.fall(&handle_sw1);
+ button1.fall(&handle_button1);
button1.mode(PullUp);
- mysw1.mode(PullUp);
- myled1 = 0;
- myled2 = 0;
- myled3 = 0;
+ myled1 = ledOff;
+ myled2 = ledOff;
+ myled3 = ledOff;
while(1) {
if (flag) {
