In your Terminal enter the command screen /dev/tty.usbmodem0000000000001 115200 and hit return twice.
00:00
You should now see the MicroPython prompt running on the Raspeberry Pi Pico.
00:00
The MicroPython build for Pico comes with libraries for controlling the Raspberry Pi Pico's pins.
We need to import the library Pin to control pins by typing: from machine import Pin
00:00
We can then create a new variable called led and assign it to a new instance of Pin. We do this with the code led = Pin(25, Pin.OUT) .
00:00
To break down what's happening in the line. We have a variable creatively called led
00:00
When creating the led variable we're making it a Pin . Pin needs two arguments.
00:00
The first argument is 25 and this is the GPIO pin we want to control.
00:00
The Raspberry Pi Pico pinout documentation tells us that the built-in LED is on GPIO pin 25.
00:00
The second argument we're providing is Pin.OUT. This tells our Pico that we want pin 25 to be an OUTPUT. We need to tell the Pico that we want the pin to be an Output because our pins are GPIOs (or General Purpose Input/Outputs).
00:00
Now that we've created our led, we can turn it on using the command led.value(1) .
00:00
The LED on our Raspberry Pi Pico will now be on.
00:00
To turn off our led we simply enter led.value(0)
00:00
main.py
xxx
Terminal
screen /dev/tty.usbmodem0000000000001 115200
>>> led = Pin(25, Pin.OUT)
>>> from machine import Pin
Breadboard
Breadboard
Mark
© 2022 Chick Commerce Pty Ltd