Programming with MicroPython: Buzzer
Import FutureBoard Library
Import the Library to make use of its functions.
from future import *03: Buzzer
1. Emitting a frequency
buzzer.tone(freq,d=0.5)Emits a sound using a frequency.
Refer to this document for the relation of frequencies and notes: https://pages.mtu.edu/~suits/notefreqs.html
Parameter d denotes the duration in seconds, use -1 for non-stop.
2. Emitting a note
buzzer.note(note,beats=1)Emits a sound using a note, value ranges from 0~130, with a total of 12 octaves, multiples of 12 are the C note of that octave.
Parameter beats controls the length, default is 1.
3. Resting
buzzer.rest(beats=1)Parameter beats controls the length, default is 1.
4. Setting the bpm
Sets the bpm(beats per minute) of the buzzer, default is 120.
5. Stopping the buzzer
6. Playing a melody
Define your own melody or use the predefined melodies with m.
Predefined Melodies:
Defining Melodies:
with c4:2 as an example:
C is the note
4 is the octave
:2 is the length
Last updated