import machine
import time
try:
# Initialize GPIO2 as output
led = machine.Pin(2, machine.Pin.OUT)
while True:
led.value(1) # Turn LED ON
sleep(0.5) # Wait for 0.5 seconds
led.value(0) # Turn LED OFF
sleep(0.5) # Wait for 0.5 seconds
except Exception as e:
# Catch and display any errors that occur
print(f"เกิดข้อผิดพลาด: {e}")
# Example function definition
def my_function(arg1, arg2):
result = arg1 + arg2 # Perform some operation (e.g., addition)
return result