
koubou no program dayo.
Dependencies: WiiClassicController_kai mbed
lancer_speaker/lancer_speaker.cpp
- Committer:
- kambara1415
- Date:
- 2016-09-02
- Revision:
- 1:e9020a93ef86
File content as of revision 1:e9020a93ef86:
#include "mbed.h" #include "lancer_speaker.h" Speaker::Speaker(PinName pin): _pin(pin){ _pin = 0; } void Speaker::tone(int freq, int duration) { _duration = duration; _freq = freq; _time.attach_us(this, &Speaker::flip, 500000/_freq); } void Speaker::noTone() { _time.detach(); } void Speaker::flip() { _pin = !_pin; if(_duration < _count*500/_freq){ _count = 0; _time.detach(); } _count++; }