Buzzer Unit

Support the following products:

Buzzer

Micropython Example:

import os, sys, io
import M5
from M5 import *
import time
from unit import BuzzerUnit

vib_0 = BuzzerUnit((33, 32))

class BuzzerUnit

Constructors

class BuzzerUnit(port)

Create an BuzzerUnit object.

The parameters are:
  • port Is the pin number of the port

UIFLOW2:

init.svg

Methods

BuzzerUnit.once(freq=10, duty=50, duration=50)

Play buzzer once.

Parameters:
  • freq (int) – The frequency of the vibration, range is 100 - 10000Hz.

  • duty (int) – The duty cycle of the vibration, range is 0 - 100.

  • duration (int) – The duration of the vibration, range is 0 - 10000ms.

UIFLOW2:

once.svg

BuzzerUnit.set_freq(freq: int)

Set the frequency of the buzzer.

Parameters:

freq (int) – The frequency of the vibration, range is 100 - 10000Hz.

UIFLOW2:

set_freq.svg

BuzzerUnit.set_duty(duty: int)

Set the duty cycle of the buzzer.

Parameters:

duty (int) – The duty cycle of the vibration, range is 0 - 100.

UIFLOW2:

set_duty.svg

BuzzerUnit.turn_off()

Turn off the buzzer.

UIFLOW2:

turn_off.svg

BuzzerUnit.deint()

Deinitialize the buzzer.

UIFLOW2:

deinit.svg