Advertisement
DeaD_EyE

WNYINYY ESP32-S3-DevKitC-1 ESP32-S3 N16R8 Dual

Apr 5th, 2024 (edited)
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. """
  2. WNYINYY ESP32-S3-DevKitC-1 ESP32-S3 N16R8 Dual
  3. WLED     -> GPIO48
  4. RED LED  -> GPIO43
  5. BLUE LED -> GPIO44
  6.  
  7. Firmware
  8. ========
  9. ESP32_GENERIC_S3-SPIRAM-OCT
  10. 8 MiB PSRAM
  11. 16 MiB SPIFlash
  12.  
  13. ESP-IDF 5.1
  14. MPY 1.23-dev
  15.  
  16. https://archive.server101.icu/micropython/esp32/ESP32_GENERIC_S3_16MIB_idf51.bin
  17. """
  18.  
  19. from time import sleep_us, sleep_ms
  20. from machine import Pin, PWM
  21. from neopixel import NeoPixel
  22.  
  23.  
  24. class PWM_Inv:
  25.     def __init__(self, pin, duty=None):
  26.         duty = duty or 1023
  27.         self.pwm = PWM(Pin(pin, Pin.OUT), duty=1023)
  28.     def duty(self, value):
  29.         self.pwm.duty(1023 - value)
  30.     def duty_u16(self, value):
  31.         self.pwm.duty(65535 - value)
  32.  
  33.  
  34. def cycle(objects):
  35.     while True:
  36.         for obj in objects:
  37.             yield obj
  38.  
  39.  
  40. def blink(pwm):
  41.     duty = cycle([range(1023), range(1023, -1, -1)])
  42.     while True:
  43.         sleep_ms(100)
  44.         for i in next(duty):      
  45.             sleep_us(i)
  46.             pwm.duty(i)
  47.  
  48.  
  49. WLED = NeoPixel(Pin(48), 1)
  50. RED = PWM_Inv(Pin(43))
  51. BLUE = PWM_Inv(Pin(44))
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement