From af01734499959ad73b2f1c1751a65f6e8f0ede94 Mon Sep 17 00:00:00 2001 From: declanshanaghy Date: Sun, 10 May 2020 12:29:49 -0700 Subject: [PATCH] Adding example of how to use a buzzer (#570) * Adding example of how to use a buzzer * Making sub-sections --- components/output/ledc.rst | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/components/output/ledc.rst b/components/output/ledc.rst index 1a72e29bd..03b15614a 100644 --- a/components/output/ledc.rst +++ b/components/output/ledc.rst @@ -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: ------------------------