Created
May 9, 2022 02:22
-
-
Save makvoid/1052ec56c7e7b330ce58b5d2a5b8d553 to your computer and use it in GitHub Desktop.
ESP-C3-32S blink example
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
# For the NodeMCU ESP32-C3–32S development kit | |
import board | |
from digitalio import DigitalInOut, Direction | |
from time import sleep | |
# Setup an LED | |
def setup_led(led_pin): | |
led = DigitalInOut(getattr(board, led_pin)) | |
led.direction = Direction.OUTPUT | |
# Ensure the LED is off | |
led.value = False | |
return led | |
# Setup the LEDs available on this board | |
led_pins = ['LED_RED', 'LED_GREEN', 'LED_BLUE', 'LED_WHITE', 'LED_YELLOW'] | |
leds = dict(zip(led_pins, map(lambda led_pin: setup_led(led_pin), led_pins))) | |
# Go through each pin and flash it 5 times | |
for led_name, led in leds.items(): | |
print('Flashing', led_name) | |
for _ in range(10): | |
led.value = not led.value | |
sleep(0.25) | |
led.value = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment