Flashing a firmware:
- Hold Bootsel white button while you connect USB
The Raspberry Pico includes a temperature sensor. See code
This is a 1602 screen with a I2C adapter.
- Download library I2C LCD for Pico
- Wire SDA, SCL, VCC to VBUS of Pico, and GND. See Pinout.
- Scan I2C devices to get the I2C address of the LCD screen (it's 0x27):
import machine
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
print(i2c.scan())
-
Drop
lcd_api.py
andpico_i2c_lcd.py
on the device, as root.ampy --port /dev/ttyACM0 put filename destination
-
Use the library:
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
i2c = I2C(0, sda=machine.Pin(0), scl=machine.Pin(1), freq=400000)
I2C_ADDR = i2c.scan()[0]
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
lcd.clear()
lcd.putstr("Hello")
-
Add the program and run it
ampy --port /dev/ttyACM0 run progname
- Setup the Pico SDK:
git clone https://github.com/raspberrypi/pico-sdk.git
- Write the C program
- Prepare
CMakeLists.txt
drwxrwxr-x 3 axelle axelle 4096 Apr 13 22:38 .
drwxrwxr-x 11 axelle axelle 4096 Apr 13 22:32 ..
drwxrwxr-x 7 axelle axelle 4096 Apr 13 22:35 build
-rw-rw-r-- 1 axelle axelle 434 Apr 13 22:35 CMakeLists.txt
-rw-rw-r-- 1 axelle axelle 193 Apr 13 22:00 greetz.c
-rw-rw-r-- 1 axelle axelle 3165 Apr 13 22:17 pico_sdk_import.cmake
- Compile:
cmake ..
, thenmake
To push on the board, use picotool
- Write your .uf2 to the board:
sudo picotool load your.uf2
- Reboot the board in application mode:
sudo picotool reboot
You can also save the current firmware (save), or see info:
$ sudo ../picotool/build/picotool info -f
The device was asked to reboot into BOOTSEL mode so the command can be executed.
Program Information
name: greetz
features: UART stdin / stdout
USB stdin / stdout
The device was asked to reboot back into application mode.
- Datasheet
- Getting started with Pico: C/C++ development manual
- Pinout
- Pros & cons on the Pico - includes PIO
- PIO state machine
- ARM Assembly with Pico
- Remote MicroPython Shell
- Ampy and TIO
- Play a melody
- I2C LCD
- UF2 Flashing Format
Ctrl-A, Ctrl-D to detach screen
- Install:
pip install adafruit-ampy
- List files on the device:
ampy --port /dev/ttyACM0 ls
- Create a directory:
ampy --port /dev/ttyACM0 mkdir /lib
- Put a file on the device
ampy --port /dev/ttyACM0 put lcd_api.py ./lib/lcd_api.py
- Run a file:
ampy --port /dev/ttyACM0 run mypython.py