Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DeflateAwning/cfc26095d25390fcd3c619176c7bf23e to your computer and use it in GitHub Desktop.
Save DeflateAwning/cfc26095d25390fcd3c619176c7bf23e to your computer and use it in GitHub Desktop.
RP2040-Zero with MicroPython Setup Guide

RP2040-Zero with MicroPython Setup Guide

  1. Install VS Code.
  2. In VS Code, install the "MicroPico" extension.
  3. Download the MicroPython firmware from: https://micropython.org/download/RPI_PICO/RPI_PICO-latest.uf2
  4. Connect the RP2040-Zero to the computer. If a USB Drive doesn't appear, press: reset-down, boot-down, reset-up, boot-up.
  5. Open the USB Drive that appeared. Copy on the MicroPython uf2 file. Wait 30 seconds.
  6. Use Device Manager (or SerialTest) to see that a new USB Serial Device appeared.
  7. In VS Code with MicroPython, see that it's connected (see the status bar at the very bottom).
  8. Optional: Run pip install micropython-rp2-rpi_pico-stubs to install Python type checking helpers.
  9. Load the rp2040_zero_onboard_led_example.py file from this gist. Name it main.py.
  10. Flash the firmware in this repo by pressing "Run".

Installing a Program

  • Use Ctrl+Shift+P -> "MicroPico: Upload project to Pico" to upload a project to the RP2040, such that it persists across reboots.

Resetting the RP2040-Zero

To reset the RP2040-Zero so that you can install a new program on it:

  1. Download the flash_nuke.uf2 file.
  2. Copy that file to the mounted USB Drive. Let it reboot.
  3. Copy the MicroPython firmware from steps above to the mounted USB Drive. Let it reboot.

Resources:

import time
from machine import Pin
from neopixel import NeoPixel
onboard_led_pin = Pin(16, Pin.OUT)
def setup() -> None:
...
def set_led_color(r: int, g: int, b: int) -> None:
"""Display a color on the LED.
Values should be between 0 and 255.
"""
np = NeoPixel(onboard_led_pin, 1)
np[0] = (r, g, b)
np.write()
def loop() -> None:
print("Basic LED Example")
brightness = 31
colors = [
(brightness, 0, 0),
(0, brightness, 0),
(0, 0, brightness),
(brightness, brightness, 0),
(0, brightness, brightness),
(brightness, 0, brightness),
(brightness, brightness, brightness),
(0, 0, 0),
]
for color in colors:
set_led_color(r=color[0], g=color[1], b=color[2])
time.sleep_ms(500)
# Run `setup` and `loop`.
setup()
while True:
loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment