From f89b6df27bc1472dc4aa9e974aec2e0f1a228292 Mon Sep 17 00:00:00 2001
From: vany5921 <908744431@qq.com>
Date: Tue, 7 Jul 2020 16:45:57 +0800
Subject: [PATCH] Create pwm.md
---
docs/en/api/pwm.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 docs/en/api/pwm.md
diff --git a/docs/en/api/pwm.md b/docs/en/api/pwm.md
new file mode 100644
index 00000000..88b090ef
--- /dev/null
+++ b/docs/en/api/pwm.md
@@ -0,0 +1,48 @@
+# PWM
+
+*PWM used to generate analog signals to drive servos or buzzers,etc.*
+
+## ledcSetup()
+
+**Syntax:**
+
+void ledcSetup(uint8_t channel, double freq, uint8_t resolution_bits);
+
+**Description:Set the PWM channel, frequency and resolution.**
+
+## ledcAttachPin()
+
+**Syntax:**
+
+void ledcAttachPin(uint8_t pin, uint8_t channel);
+
+**Description:Bind the LEDC channel to the specified IO port to achieve output.**
+
+## ledWrite()
+
+**Syntax:**
+
+void ledcWrite(uint8_t channel, uint32_t duty);
+
+**Description:Output waveform to the channel channel according to the specified duty cycle.**
+
+**Example:**
+```arduino
+#include
+int freq = 1800;
+int channel = 0;
+int resolution_bits = 8;
+int buzzer = 2;
+
+void setup() {
+ M5.begin();
+ ledcSetup(channel, freq, resolution_bits);
+ ledcAttachPin(buzzer, channel);
+}
+void loop() {
+ ledcWrite(channel, 128);
+ delay(1000);
+ ledcWrite(channel, 0);
+ delay(1000);
+}
+```
\ No newline at end of file