pdf-icon

Buzzer

Example

#include <M5StickCPlus.h>

void setup() {
    M5.begin();
    M5.Beep.tone(4000, 300);
}

void loop() {
    M5.update();
}

begin

Syntax:

void begin();

Description:

  • Initialize Buzzer, this function will be called automatically when you pass M5.begin();.

Parameters:

  • null

Return:

  • null

update

Syntax:

void update();

Description:

  • Update Buzzer Play status, for the function which set Play duration, need to call this function continuously to update the status. This function will be called automatically when you pass M5.update();.

Parameters:

  • null

Return:

  • null

end

Syntax:

void end();

Description:

  • Inverse initialization, free Buzzer IO resources.

Parameters:

  • null

Return:

  • null

mute

Syntax:

void mute();

Description:

  • Mute Play

Parameters:

  • null

Return:

  • null

tone

Syntax:

void tone(uint16_t frequency);
void tone(uint16_t frequency, uint32_t duration);

Description:

  • Control of tone frequency

Parameters:

  • uint16_t frequency:
    • tone frequency
  • uint32_t duration:
    • duration time

Return:

  • null

beep

Syntax:

void beep();

Description:

  • Controlled audible beep, default audible frequency 4000Hz, duration 100ms

Parameters:

  • null

Return:

  • null

setBeep

Syntax:

void setBeep(uint16_t frequency, uint16_t duration);

Description:

  • Configuring parameters for the Beep tone

Parameters:

  • uint16_t frequency:
    • beep frequency
  • uint32_t duration:
    • beep duration

Return:

  • null

write

Syntax:

void write(uint8_t value);

Description:

  • Write Buzzer Driver DAC Analog Values

Parameters:

  • uint8_t value:
    • DAC Analog Value

Return:

  • null

setVolume

Syntax:

void setVolume(uint8_t volume);

Description:

  • Sets the Play volume, valid only for the playMusic function.

Parameters:

  • uint8_t volume:
    • volume

Return:

  • null

playMusic

Syntax:

void playMusic(const uint8_t *music_data, uint16_t sample_rate);

Description:

  • Play of raw PCM audio data

Parameters:

  • const uint8_t *music_data:
    • Play Data Pointer
  • uint16_t sample_rate:
    • Play data sample rate

Return:

  • null
On This Page