This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

lm ambient buzzer
#5
(20.05.2021, 08:51)admin Wrote: Buzzer control for new HW (with volume control):
Code:
function beep(note, time, volume)
  volume = volume or 10
  volume = 1 + (11 - volume) ^ 2

  local period = math.floor(10 ^ 9 / note)
  local cycle = math.floor(period / volume)
  local path = '/sys/class/pwm/pwmchip3/pwm0/'

  io.writefile(path .. 'period', period)
  io.writefile(path .. 'duty_cycle', cycle)

  io.writefile(path .. 'enable', 1)
  os.sleep(time or 0.1)
  io.writefile(path .. 'enable', 0)
end

Thanks it works, and how lower the volume value, how harder the buzzer?

And is it correct that this device doesn't display a pm25 value?
Reply


Messages In This Thread
lm ambient buzzer - by gjniewenhuijse - 20.05.2021, 05:53
RE: lm ambient buzzer - by Daniel - 20.05.2021, 08:14
RE: lm ambient buzzer - by gjniewenhuijse - 20.05.2021, 08:39
RE: lm ambient buzzer - by admin - 20.05.2021, 08:51
RE: lm ambient buzzer - by gjniewenhuijse - 20.05.2021, 08:58
RE: lm ambient buzzer - by admin - 20.05.2021, 09:04

Forum Jump: