-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblink.py
33 lines (27 loc) · 841 Bytes
/
blink.py
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
#-----------------------------------------------------------------------------#
# Blink
#
# Micropython code for Raspberry Pi Pico w
#
# File : blink.py
# Source : https://github.com/RPiSpy/pi-pico
#
# Desc : Blink the on-board LED
# Hardware : Pi Pico or Pi Pico W
# Software : n/a
#
# Author : Matt Hawkins
# Website : https://www.raspberrypi-spy.co.uk/
#-----------------------------------------------------------------------------#
from machine import Pin, Timer
# Frequency that LED is toggled.
# 2Hz is 2 toggles per second = 1 flash per second
BLINK_FREQ = 2
led = Pin("LED", Pin.OUT)
# Create timer object
timer = Timer()
# Define function to toggle LED state
def blink(timer):
led.toggle()
# Setup timer to call blink function every 2 seconds
timer.init(freq=BLINK_FREQ, mode=Timer.PERIODIC, callback=blink)