44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
# Micropython version of the blink program
|
|
|
|
import machine
|
|
import time
|
|
|
|
print("\nMicroPython example code")
|
|
print("Blink the onboard LED and LED's connected to GP15 & GP16\n")
|
|
|
|
ledList = ['LED', 'GP15', 'GP16']
|
|
ledPinList = [
|
|
machine.Pin('LED', machine.Pin.OUT), #configure LED Pin as an output pin and create and led object for Pin class
|
|
# Configure GP15
|
|
machine.Pin('GP15', machine.Pin.OUT), #configure LED Pin as an output pin and create and led object for Pin class
|
|
# Configure GP16
|
|
machine.Pin('GP16', machine.Pin.OUT) #configure LED Pin as an output pin and create and led object for Pin class
|
|
]
|
|
|
|
def cycleLED(ledID,timeDelay):
|
|
ledID.value(True)
|
|
time.sleep(timeDelay)
|
|
ledID.value(False)
|
|
time.sleep(timeDelay)
|
|
|
|
def turnOffLED(ledID):
|
|
ledID.value(False)
|
|
|
|
print("Turn off all LED's")
|
|
#turnOffLED(led)
|
|
#turnOffLED(led15)
|
|
#turnOffLED(led16)
|
|
|
|
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
|
|
|