17.05.2021, 14:46
(This post was last modified: 17.05.2021, 14:52 by gjniewenhuijse.)
(11.04.2017, 07:51)admin Wrote: 2. Try this:
Code:function beep(freq, time)
local path = '/sys/class/pwm/pwmchip0/pwm1/'
io.writefile(path .. 'enable', 1)
local period = math.floor(10 ^ 9 / freq)
local cycle = math.floor(period / 2)
io.writefile(path .. 'period', period)
io.writefile(path .. 'duty_cycle', cycle)
os.sleep(time)
io.writefile(path .. 'enable', 0)
end
-- 700hz for 1/10 second
beep(700, 0.1)
Is this code still working? because my ambient doesn't beep
And is it also possible to control the buzzer volume from this script?