Flash a light

The first project you do with any new piece of hardware: flash a light.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from digitalio import DigitalInOut, Direction
import board
import time

# Built in red LED
led = DigitalInOut(board.LED)
led.direction = Direction.OUTPUT

while True:
    led.value = True
    time.sleep(0.5)
    led.value = False
    time.sleep(0.5)