Skip to content

Instantly share code, notes, and snippets.

@jkuester
Last active August 15, 2024 23:29
Show Gist options
  • Save jkuester/46d63c9d84f4aee97544578f3f5fbc6e to your computer and use it in GitHub Desktop.
Save jkuester/46d63c9d84f4aee97544578f3f5fbc6e to your computer and use it in GitHub Desktop.
MicroPython on DEV CON 32 Badge

Resources

Most helpful documentation:

Additional Links:


Setup badge

You can flash the MicroPython ROM to the badge just like flashing the other .uf2 files via mounting the device as a drive and copying the .uf2 over. Once it reboots, you should be able to connect to the MicroPython session.

Setting up dev environment

  • Install minicom: sudo apt install minicom
  • Make sure you are a member of the dialout group so that you have access to the serial device

Connecting to device

# Find device
ls /dev/ttyACM*
  
# Open repl with minicom
minicom -o -D /dev/ttyACM0

Note that it seems like you can only have one session connected at a time. This includes minicom, mpremote, and the VS Code plugin

To exit minicom:

hit enter. then cntl-A then q then enter to exit minicom.

Making the lights do stuff

To contol the lights, it is useful to use the neopixal library. To install this library to the badge you will need to do the following:

# Install the neopixel library on the device
mpremote mip install neopixel

More info about neopixel can be found in this tutorial.

import neopixel

pin = machine.Pin.board.GP4
ledStrip = neopixel.NeoPixel(pin, 10)

# Draw a red gradient.
# for i in range(10):
#     n[i] = (i * 8, 0, 0)

# Set eye red
ledStrip[5] = (255, 0, 0)


ledStrip.write()
print("Make it glow")

Setting up VS Code

You can connect VS Code to your badge for a nice IDE instead of doing everything in a minicom repl. Check out this tutorial for more info.

(Do not forget that you can only have one session at a time, so if you are connected via minicom you will not be able to connect VS Code. If you are connected in VS Code you will not be able to run mpremote.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment