スピーカーで音を鳴らす
Dependencies: mbed
main.cpp
- Committer:
- hagi_hara
- Date:
- 2015-08-15
- Revision:
- 2:44b8465482f9
- Parent:
- 1:42c121dda003
- Child:
- 3:722a88ffb4f7
File content as of revision 2:44b8465482f9:
//example_01_speaker //スピーカーを鳴らすサンプルコード #include "mbed.h" #define SP_OFF 0.0 #define SP_ON 0.5 #define mC 261.626 //「ド」の周波数(Hz) PwmOut speaker(dp1);//dp1ピンを出力ピンに設定 int main() { //音を鳴らす speaker.period(1.0/mC); speaker.write(SP_ON); //5秒待つ wait(5.0); //音を止める speaker.write(SP_OFF); while(true); }