スピーカーで音を鳴らす

Dependencies:   mbed

main.cpp

Committer:
hagi_hara
Date:
2015-08-15
Revision:
0:f5bba12ef049
Child:
1:42c121dda003

File content as of revision 0:f5bba12ef049:

//スピーカーを鳴らすサンプルコード
#include "mbed.h"

#define mC 261.626 //「ド」の周波数

//ピン設定
PwmOut speaker(dp18);

int main()
{
    //音を鳴らす
    speaker.period(1.0/mC);
    speaker = 0.5;

    //5秒待つ
    wait(5.0);
    
    //音を止める
    speaker = 0.0;
    
    
    while(true)
}