Here are some useful links and basic code snippets!
Adafruit CircuitPython library bundle (you shouldn't need this if you're using the VS Code extension)
CircuitPython v2 VS Code extension
My etch a sketch mouse tutorial
Adafruit HID docs and examples using mouse, keyboard and gamepad
Custom HID descriptors (more complex)
Cool stuff to do with Velostat (electronic circuits made of fabric)
There are plenty of good online stores for electronics equipment but the 3 I like most are
The Pi Hut - very thorough collection and good documentation on most listings
Pimoroni - more suited to kits and fun variants on the basics (e.g. they do a pi pico but it's huge)
CPC Farnell - good if you're doing a bulk order and you know exactly what you want, will be a bit cheaper than Pi Hut or Pimoroni - but worse UX and I've definitely ordered the wrong thing before because the description wasn't as clear
- Download UF2 for the correct board (28th July: we are using Pi Pico, not W, not 2)
- Plug Pico into your computer with a decent USB Micro cable.
- Copy UF2 to root of device.
- Open VS Code with extension installed.
- CircuitPython: Select Serial Port -> click whatever it says
- CircuitPython: Choose CircuitPython Board -> Raspberry Pi:Pico
- CircuitPython: Open Serial Monitor
- Install dependencies: CircuitPython: Show Available Libraries
- Write code
- Hack
- Have fun!
import board
import digitalio
from time import sleep
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
sleep(1)
led.value = False
sleep(1)
import time
import board
from digitalio import DigitalInOut, Direction, Pull
led = DigitalInOut(board.LED)
led.direction = Direction.OUTPUT
switch = DigitalInOut(board.GP15)
switch.direction = Direction.INPUT
switch.pull = Pull.UP
while True:
if switch.value:
led.value = False
else:
led.value = True
time.sleep(0.01)
import board
import digitalio
from adafruit_debouncer import Debouncer
pin = digitalio.DigitalInOut(board.GP15)
pin.direction = digitalio.Direction.INPUT
pin.pull = digitalio.Pull.UP
switch = Debouncer(pin)
while True:
switch.update()
if switch.fell:
print('Just pressed')
if switch.rose:
print('Just released')
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from time import sleep
keyboard = Keyboard(usb_hid.devices)
while True:
keyboard.send(Keycode.CAPS_LOCK)
sleep(1)
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from time import sleep
keyboard = Keyboard(usb_hid.devices)
while True:
keyboard.press(Keycode.CAPS_LOCK)
sleep(0.5)
keyboard.release(Keycode.CAPS_LOCK)
sleep(1)