PWMMelody
Last updated
Was this helpful?
Last updated
Was this helpful?
This example shows how to use the PWMOut
to generate notes. It plays a little melody which you may have heard before.
SwiftIO board
Jumper wires
Piezo buzzer or a speaker
SwiftIO shield (optional)
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.
- The PWMOut class is used to change the time of high voltage during one period to simulate different output.