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: TextLCD mbed MMA8451Q TSI
Diff: Button.cpp
- Revision:
- 0:f48fccfff709
- Child:
- 1:47973f27d645
diff -r 000000000000 -r f48fccfff709 Button.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Button.cpp Fri Aug 14 10:35:11 2015 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "Speaker.h" + +class Button { +public: + Button(PinName pin, int note, Speaker* s, DigitalOut* myled) : _interrupt(pin) { + _code=note; + led=myled; + speaker=s; + _interrupt.rise(this, &Button::press); + _interrupt.fall(this, &Button::release); + } + + void press() { + speaker->PlayNote(_code, 0.3, 0.2); + *led=1; + } + + void release() { + *led=0; + } + +private: + InterruptIn _interrupt; + int _code; + Speaker* speaker; + DigitalOut* led; +}; \ No newline at end of file