First step in making the code to be more independent on each board. This version is just for TinyBLE, the next will be a bit more generic

Dependencies:   BLE_API mbed nRF51822

Fork of EddystoneBeaconSwitchLed by Roy Want

main.cpp

Committer:
scottjenson
Date:
2015-09-29
Revision:
3:2340e6920afe
Parent:
2:fc105f4c854e

File content as of revision 3:2340e6920afe:

#include "mbed.h"
#include "BLEDevice.h"
#include "DeviceInformationService.h"

int ledOn = 0;
int ledOff = 1;

InterruptIn button1(P0_17);
InterruptIn mysw1(P0_18);
DigitalOut myled1(P0_21);
DigitalOut myled2(P0_22);
DigitalOut myled3(P0_23);
// Serial pc(USBTX,USBRX);
int flag = false;

void handle_button1() {
    flag = !flag;
    }


void ledflasher() {
        myled1 = ledOn;
        wait(0.3);
        myled1 = ledOff;
        myled2 = ledOn;
        wait(0.3);
        myled2 = ledOff;
        myled3 = ledOn;
        wait(0.4);   
        myled3 = ledOff; 
    }

int main() {
    // Initialize button1 and pull up
    // set interrupt callback for button1    
    button1.fall(&handle_button1);
    button1.mode(PullUp);
    myled1 = ledOff;
    myled2 = ledOff;
    myled3 = ledOff;

    while(1) {
        if (flag) {
            ledflasher();
        }
        wait(0.2);
    }
    
    
    
}