Simple library for controlling LEDs. Turn them on & off, blink them at specified rates and toggle their output. Don't forget to add a timer for the LEDs to use. Documentation found in header file.
LEDControl.cpp
- Committer:
- wakestrap
- Date:
- 2015-07-09
- Revision:
- 0:8aa281e74b4a
- Child:
- 1:1f6bd61833a3
File content as of revision 0:8aa281e74b4a:
#include "LEDControl.h" #include "mbed.h" LEDControl::LEDControl(PinName pin, Timer *time): _led(pin), _nextBlink( 0 ), _Time ( time ) { _led = 0; } void LEDControl::blink(float rate) { long _currentTime = _Time->read_ms(); if(_currentTime - _nextBlink > 0) { if(_currentTime > 20000000) { _Time->reset(); _currentTime = 0; } _led = !_led; _nextBlink = 1000/rate + _currentTime; } } void LEDControl::off() { _led = 0; } void LEDControl::on() { _led = 1; } void LEDControl::toggle() { _led = !_led; }