PWMMelody

This example shows how to use the PWMOut to generate notes. It plays a little melody which you may have heard before.
What you need
SwiftIO board
Jumper wires
Piezo buzzer or a speaker
SwiftIO shield (optional)
Circuit

Code
Instruction
The code above uses a Frequency as musical pitches. For example, NOTE_C4 is middle C, whose frequency is 262 Hz. Latter example MidiPlayer we will markdown all this musical note in a file. This file contains all the pitch values for typical notes. You may find it useful whenever you want to make musical notes.
See Also
PWMOut - The PWMOut class is used to change the time of high voltage during one period to simulate different output.
References
Last updated
Was this helpful?