Emits asynchroneous tone output in a similar way to CgnDO class.
More...
#include <cgnuino.h>
|
| CgnTone (byte) |
| Consructor. More...
|
|
void | update () |
| Stop the tone when finished determined time length of output. More...
|
|
void | out (uint32_t, uint16_t=440) |
| Starts a tone out from a pin for determined time length. More...
|
|
In order to asynchroneously emit digital outputs, cgnuino has CgnDO class dedicated to that purpose. The same demand for tone output instead of digital outputs can be met by CgnTone class. The usage is almost identical to CgnDO class except that CgnTone class only use one out pin, instead of holding multiple digital-out pins. (Usually multiple tone outputs are not required in standard behavioral tasks.) Start beeping a piezo buzzer in a required frequency by out
method. Then repeatedly call update
method so that it can terminate tone output once a designated time length has passed.
CgnTone::CgnTone |
( |
byte |
tonePin | ) |
|
- Parameters
-
tonePin | Pin number for digital-out to a piezo buzzer. |
void CgnTone::out |
( |
uint32_t |
toneMs, |
|
|
uint16_t |
toneFreq = 440 |
|
) |
| |
- Parameters
-
toneMs | Time length of output in [ms]. |
toneFreq | Frequency of tone output in [Hz]. |
- Note
- For a normal usage, this method is intended to be called once inside
loop
function.
The documentation for this class was generated from the following files: