Lab 8-Pico W Introduction
This commit is contained in:
parent
1e1bddf63c
commit
c7ac62b6b3
26 changed files with 8387 additions and 5 deletions
48
Lab08/CircuitPython/Code/blink_external_cycle3.py
Normal file
48
Lab08/CircuitPython/Code/blink_external_cycle3.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Program for CircuitPython on a Pico W
|
||||
|
||||
import board
|
||||
import digitalio
|
||||
import time
|
||||
|
||||
print("\nCircuitPython example code")
|
||||
print("Cycle the onboard LED and LED's connected to GP15 & GP16\n")
|
||||
|
||||
|
||||
ledList = ['LED', 'GP15', 'GP16']
|
||||
ledPinList = [
|
||||
digitalio.DigitalInOut(board.LED),
|
||||
digitalio.DigitalInOut(board.GP15),
|
||||
digitalio.DigitalInOut(board.GP16)
|
||||
]
|
||||
|
||||
def cycleLED(ledID,timeDelay):
|
||||
ledID.value = True
|
||||
time.sleep(timeDelay)
|
||||
ledID.value = False
|
||||
time.sleep(timeDelay)
|
||||
|
||||
def turnOffLED(ledPinList):
|
||||
for pinID in ledPinList:
|
||||
pinID.value = False
|
||||
|
||||
|
||||
for pinID in ledPinList:
|
||||
pinID.direction = digitalio.Direction.OUTPUT
|
||||
|
||||
print("Turn off all LED's")
|
||||
turnOffLED(ledPinList)
|
||||
|
||||
timeDelay = .25
|
||||
print("Cycle LEDs")
|
||||
|
||||
while True:
|
||||
|
||||
print("Cycle start")
|
||||
cycleLED(ledPinList[0],timeDelay)
|
||||
cycleLED(ledPinList[1],timeDelay)
|
||||
cycleLED(ledPinList[2],timeDelay)
|
||||
cycleLED(ledPinList[1],timeDelay)
|
||||
|
||||
# time.sleep(1) #wait for one second
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue