Konrad Zakrzewski
/
ME21001_Lab02_Exercise_06
buzzer on/off
main.cpp
- Committer:
- kzakrzewski
- Date:
- 2018-10-03
- Revision:
- 0:c418d4724781
File content as of revision 0:c418d4724781:
/************************************************************** / Simple program to show basic program structure / / The program play sound on/off at a rate of 500Hz in 1ms intervals / /**************************************************************/ #include "mbed.h" // speaker sound effect demo using PWM hardware output PwmOut speaker(p21); int main() { while (1) { // generate a 500Hz tone using PWM hardware output speaker.period(1.0/500.0); // 500hz period speaker =0.5; //50% duty cycle - max volume wait(0.001); speaker=0.0; // turn off audio wait(0.001); } }