-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
39 lines (30 loc) · 775 Bytes
/
code.py
File metadata and controls
39 lines (30 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
##
import board
import digitalio
import time
# Variables
delay = 1.5
# Set leds to digital pins
red = digitalio.DigitalInOut(board.D1)
yellow = digitalio.DigitalInOut(board.D2)
green = digitalio.DigitalInOut(board.D3)
# Set directions for leds
red.direction = digitalio.Direction.OUTPUT
yellow.direction = digitalio.Direction.OUTPUT
green.direction = digitalio.Direction.OUTPUT
led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT
# Run code
while True:
# Red light
red.value = True
time.sleep(3 * delay)
red.value = False
# Green light
green.value = True
time.sleep(5 * delay)
green.value = False
# Yellow light
yellow.value = True
time.sleep(2 * delay)
yellow.value = False