Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GROVE_SOUND.cpp
- Committer:
- ngomez
- Date:
- 2017-07-02
- Revision:
- 0:fa75a7cf49b6
File content as of revision 0:fa75a7cf49b6:
#include "GROVE_SOUND.h" #include "mbed.h" GROVE_SOUND::GROVE_SOUND(PinName pin) : _pin(pin){ sum = 0; average = 0; } float GROVE_SOUND::get_decibels(){ float values[1000]; for(int i=0;i<1000;i++){ values[i] = _pin.read()* 3.3; wait(0.0001); } for(int j=0;j<1000;j++){ sum += values[j]; } average = sum/1000; decibels = average * 29; return decibels; }