pdf-icon

Arduino入門

2. デバイス&サンプル

StickC-Plus Buzzer

Example

cpp
1 2 3 4 5 6 7 8 9 10
#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
Example
begin
update
end
mute
tone
beep
setBeep
write
setVolume
playMusic
Q&A
Submit a question
Select question category*
Arduino
MicroPython
UIFlow1
UIFlow2
EzData
M5Burner
Software
Hardware
Other
Product name
Product version
Question description*
(Supports pasting screenshots.)
Attachments
Add Files
Email*
Submit
OK

M5Stack Support

Hi, this is M5Stack Support. How can I help you today?