mirror of
https://github.com/esphome/esphome-docs.git
synced 2025-01-26 22:21:38 +01:00
Adding example of how to use a buzzer (#570)
* Adding example of how to use a buzzer * Making sub-sections
This commit is contained in:
parent
9b6170ac60
commit
af01734499
@ -12,6 +12,9 @@ of the ESP32 as an output component.
|
||||
The frequency range of LEDC is from 10Hz to 40MHz - however, higher frequencies require a smaller
|
||||
bit depth which means the output is not that accurate for frequencies above ~300kHz.
|
||||
|
||||
Example Usage For a Light
|
||||
*************************
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
@ -26,6 +29,40 @@ bit depth which means the output is not that accurate for frequencies above ~300
|
||||
output: gpio_19
|
||||
name: "Kitchen Light"
|
||||
|
||||
Example Usage For a Piezo Buzzer
|
||||
********************************
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Configure the output
|
||||
output:
|
||||
- platform: ledc
|
||||
######################################################
|
||||
# One buzzer leg connected to GPIO12, the other to GND
|
||||
######################################################
|
||||
pin: GPIO12
|
||||
id: buzzer
|
||||
|
||||
# Example usage in an automation
|
||||
on_press:
|
||||
then:
|
||||
######################################################
|
||||
# Must be turned on before setting frequency & level
|
||||
######################################################
|
||||
- output.turn_on: buzzer
|
||||
######################################################
|
||||
# Frequency sets the wave size
|
||||
######################################################
|
||||
- output.ledc.set_frequency:
|
||||
id: buzzer
|
||||
frequency: "1000Hz"
|
||||
######################################################
|
||||
# level sets the %age time the PWM is on
|
||||
######################################################
|
||||
- output.set_level:
|
||||
id: buzzer
|
||||
level: "50%"
|
||||
|
||||
Configuration variables:
|
||||
------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user