Piezo buzzer Lua [NodeMCU] library
local piezo = require('piezo32')({
gpio = 13
})
Play sound at 1kHz for 10 times with play duration of 100ms and rest duration of 100ms as well
piezo.play({
freq = 1000,
play_duration = 100,
pause_duration = 100,
times = 10
})
Two beeps - success sound
piezo.success()
Low frequency error sound
piezo.error()
Jingle Bells
piezo.play_music('E1E1E2E1E1E2E1G1C1D1E4F1F1F1F1F1E1E1E1E1D1D1E1D2G2')
Mary Had a Little Lamb
piezo.play_music('B1A1G1A1B1B1B2A1A1A2B1B1B2B1A1G1A1B1B1B2A1A1B1A1G2G2')
Twinkle Twinkle Little Star
piezo.play_music('C1C1G1G1A1A1G2F1F1E1E1D1D1C2')
Project depends on the following NodeMCU modules:
tmr
ledc