Created
October 29, 2018 09:08
-
-
Save faaaaabi/941e38326b24bd2b23c6979186386080 to your computer and use it in GitHub Desktop.
Function for MicroPython on ESP32 which generates PWM signal on given pin. Based on: http://docs.micropython.org/en/latest/esp8266/quickref.html#pwm-pulse-width-modulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_led_pulse(nPulses, pin): | |
import machine | |
import time, math | |
led = machine.PWM(machine.Pin(pin), freq=1000) | |
for j in range(pulses): | |
for i in range(20): | |
led.duty(int(math.sin(i / 10 * math.pi) * 500 + 500)) | |
time.sleep_ms(50) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment