Creality Board Klipper Beeper M300 Buzzer gcode

Daniel Jordan Osborn
2 min readDec 28, 2021
creality_board_schematics_screenshot

I have an Ender 3 with a 4.2.7 Board running Klipper firmware and wanted to enable the Buzzer. After some looking around I found the sample_macros.cfg and PDF schematics for both 4.2.2 and 4.2.7. Using these two things I was able to make the M300 gcode command trigger the Buzzer in the LCD panel.

######################################################################
# Beeper
######################################################################
# M300 : Play tone. Beeper support, as commonly found on usual LCD
# displays (i.e. RepRapDiscount 2004 Smart Controller, RepRapDiscount
# 12864 Full Graphic). This defines a custom I/O pin and a custom
# GCODE macro. Usage:
# M300 [P<ms>] [S<Hz>]
# P is the tone duration, S the tone frequency.
# The frequency won't be pitch perfect.
[output_pin BEEPER_pin]
pin: PC6
# Beeper pin. This parameter must be provided.
# ar37 is the default RAMPS/MKS pin.
pwm: True
# A piezo beeper needs a PWM signal, a DC buzzer doesn't.
value: 0
# Silent at power on, set to 1 if active low.
shutdown_value: 0
# Disable at emergency shutdown (no PWM would be available anyway).
cycle_time: 0.001
# Default PWM frequency : 0.001 = 1ms will give a tone of 1kHz
# Although not pitch perfect.
[gcode_macro M300]
gcode:
# Use a default 1kHz tone if S is omitted.
{% set S = params.S|default(1000)|int %}
# Use a 10ms duration is P is omitted.
{% set P = params.P|default(100)|int %}
SET_PIN PIN=BEEPER_pin VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
G4 P{P}
SET_PIN PIN=BEEPER_pin VALUE=0

The only thing you need to change from the sample_macros.cfg section is the pin. Under [output_pin BEEPER_pin] you set pin:PC6. That is it. Hope this helps someone or me in the future at least.

--

--

Daniel Jordan Osborn

I can't find anything, all I do is look and look. By the time I found that one thing, that other thing I was holding, it's lost... :wq