# Start by importing lib files "machine" & "time" # Imports the machine module, which provides access to hardware features such as GPIO pins, ADCs, PWM, etc. import machine # Imports the time module, which provides delay functions like sleep(). import time #we're initalizing pin 25 (which is the onboard LED) & GPIO pins 2, 6 and 10 as outputs (These are the GPIO numbers, not the actual pin numbers around the PCB). # Creates a pin object called led1. # Uses GPIO pin 25. # Sets the pin mode to output (Pin.OUT). # On a Raspberry Pi Pico, GPIO 25 is usually connected to the onboard LED. led1 = machine.Pin(25, machine.Pin.OUT) # Creates an output pin object for GPIO 2 (GP2). led2 = machine.Pin(2, machine.Pin.OUT) # Creates an output pin object for GPIO 6 (GP6). led3 = machine.Pin(6, machine.Pin.OUT) # Creates an output pin object for GPIO 10 (GP10). led4 = machine.Pin(10, machine.Pin.OUT) #Run a loop 5 times # Starts a loop that repeats 5 times. # The variable i takes values from 0 to 5. for i in range(5): # Sets GPIO 2 HIGH (3.3V). # Turns LED 2 on (assuming the LED is wired active-high). led2.value(1) # Sets GPIO 6 & 10 LOW. # Turns LED 3 and 4 off. led3.value(0) led4.value(0) #Use time to wait for 0.5 second time.sleep(0.2) # The rest of the code is a repetition of what has been done above. #Turn the onbaord LED off led1.value(0) #Turn external LED on pin 2 (only) on #led1.value(0) led2.value(1) led3.value(0) led4.value(0) #Use time to wait for 1 second time.sleep(0.11) #Turn external LED on pin 3 (only) on #led1.value(0) led2.value(0) led3.value(1) led4.value(0) #Use time to wait for 1 second time.sleep(0.2) #Turn external LED on pin 4 (only) on #led1.value(0) led2.value(0) led3.value(0) led4.value(1) #Use time to wait for 1 second time.sleep(0.2) #Turn the external LED on pin 4 off led4.value(0)