print("Hello, ESP32!")
from machine import Pin
import time
# Define the pin numbers for the 8 LEDs
led_pins = [2, 4, 17, 5, 18, 19, 21, 23]
button = Pin(14, Pin.IN)
# Initialize the LED pins
leds = [Pin(pin, Pin.OUT) for pin in led_pins]
def running_lights(direction, delay):
for i in range(len(leds)):
# Turn on the current LED
leds[i].on()
time.sleep_ms(delay)
# Turn off the current LED
leds[i].off()
if direction == 'left':
leds.reverse()
# Set the initial direction and delay
current_direction = 'left'
delay_ms = 250
# Run the running lights
while True:
running_lights(current_direction, delay_ms)
time.sleep(0.5) # Wait for a short duration before changing direction
current_direction = 'right' if current_direction == 'left' else 'left'