Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- WNYINYY ESP32-S3-DevKitC-1 ESP32-S3 N16R8 Dual
- WLED -> GPIO48
- RED LED -> GPIO43
- BLUE LED -> GPIO44
- Firmware
- ========
- ESP32_GENERIC_S3-SPIRAM-OCT
- 8 MiB PSRAM
- 16 MiB SPIFlash
- ESP-IDF 5.1
- MPY 1.23-dev
- https://archive.server101.icu/micropython/esp32/ESP32_GENERIC_S3_16MIB_idf51.bin
- """
- from time import sleep_us, sleep_ms
- from machine import Pin, PWM
- from neopixel import NeoPixel
- class PWM_Inv:
- def __init__(self, pin, duty=None):
- duty = duty or 1023
- self.pwm = PWM(Pin(pin, Pin.OUT), duty=1023)
- def duty(self, value):
- self.pwm.duty(1023 - value)
- def duty_u16(self, value):
- self.pwm.duty(65535 - value)
- def cycle(objects):
- while True:
- for obj in objects:
- yield obj
- def blink(pwm):
- duty = cycle([range(1023), range(1023, -1, -1)])
- while True:
- sleep_ms(100)
- for i in next(duty):
- sleep_us(i)
- pwm.duty(i)
- WLED = NeoPixel(Pin(48), 1)
- RED = PWM_Inv(Pin(43))
- BLUE = PWM_Inv(Pin(44))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement