Simple Blinky library.

Dependents:   Blinky_Tests

Fork of Blinky by Sarah Marsh

Blinky.cpp

Committer:
mbed_demo
Date:
2016-11-08
Revision:
2:256c8d48f5e7
Parent:
1:5b51a271d47e

File content as of revision 2:256c8d48f5e7:

#include "Blinky.h"

Blinky::Blinky(PinName led, int interval):
        _led(led), _interval(interval){
    stop_blink=false;
    _led=1;
    led_count = 0;
    
}
float Blinky::times_blinked(){
    return led_count;
}

void Blinky::start(){
    _blinker.start(this, &Blinky::blink_led);
} 
void Blinky::stop(){
    stop_blink = true;
    _blinker.join();
}  
void Blinky::blink_led(){
    while (!stop_blink){
        _led = !_led;
        led_count += 0.5;
        Thread::wait(_interval);
    }
}