koubou no program dayo.

Dependencies:   WiiClassicController_kai mbed

Revision:
1:e9020a93ef86
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lancer_speaker/lancer_speaker.cpp	Fri Sep 02 00:28:49 2016 +0000
@@ -0,0 +1,29 @@
+#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++;
+}
\ No newline at end of file