Raspberry Pi Pico & Pico Explorer Workout

by tonygo2 in Circuits > Microcontrollers

8629 Views, 20 Favorites, 0 Comments

Raspberry Pi Pico & Pico Explorer Workout

Wire up.jpg
CharSet.jpg

In this Instructable I'm going to demonstrate the new Raspberry Pi PICO microcontroller board for Physical Computing and Graphics using the Pimoroni PICO EXPLORER.

I am going to assume that you have installed the Pimoroni UF2 file to your Pico, installed the Thonny Editor on your computer, know how to connect your Pico to your computer's USB port, enter and run code from Thonny.

(I've updated this tutorial to use the updated Pimoroni UF2 file 0.0.7 - 17th Feb 2021)

Pimoroni have supplied a few graphics commands - screen clear, filled rectangles and circles, pen colours, pixel, text string and text character printing to the screen.

This demonstration adds lines, hollow rectangles and circles, bar and line graphs, user defined characters and how to combine them in various ways to scroll text cross the screen and react to physical changes as buttons are pressed and a potentiometer knob is turned.

I hope you will find it useful.

Supplies

Raspberry Pi PICO

Pimoroni Pico Explorer and associated UF2 file (Currently 0.

Suitable USB lead

10K Ohm potentiometer

LED

470 Ohm resistor

Jumper wires

Thonny Editor

Wire Up

Wire up.jpg

The picture shows how to wire up the breadboard. Once this has been done push the potentiometer into the breadboard at the right side to cover the two short black and orange wires. The wiper leg should be at the top, between the two wires.

The demonstration will work without the components and demonstrates the graphical capabilities of the board but with less user control.

At this point you can download the MicroPython file and run it.

The following pages look at the code and add comments/observations

Basic Boilerplate and Procedures

1-28 B.jpg
ExplorerFilm

This sets up the display and has routines to clear the screen to black and write titles for each section of code.

Lines and Boxes

29-61.jpg

These routines provide vertical and horizontal lines, lines between two points and hollow rectangles.

Alignment and Circles

63-89.jpg

Here are routines to update the screen and pause a short while, left align text by inserting extra spaces and two methods of drawing hollow circles.

Bar Graph and User Defined Characters (small)

90-122.jpg

These routines draw a bar graph and show how to define 7x5 pixel characters and display them at twice the size. The pixels are so small on this screen that at normal size you cannot really see them effectively.

Larger Defined Characters

123-137.jpg

This routine draws the predefined characters at size 3.

Basic Stuff

138-172.jpg
Chars.jpg

Here we start the main program showing lines, circles, a box and predefined characters at two sizes

Character Set

173-200.jpg
CharSet.jpg

Notice that the text can set to various sizes. Size 1 is very difficult to read and size 6 is rather crude. There are no lower case letters - probably to save space. The type face is an unusual choice.

'~' has been replaced at the end with a right leaning single quote.

Long strings will text wrap at a 'space' character.

A Load of Lines

201-236.jpg
lines.jpg

Lines at any angle and drawn pretty quickly.

Sine and Cosine Curves

237-263.jpg
graphs.jpg

Notice the speed difference with display.update() inside and outside the loop

Text on a Path

264-283.jpg

Pretty easy to do

Scrolling Text on a Path - Setup

284-302.jpg

Scrolling on a Path - the Loop

303-329.jpg
scrolling.jpg

I was impressed by the speed the pico and display managed this. There is a great deal going on.

Physical Computing - Potentiometer, LED With PWM, Bar Graph and Button

330-363.jpg
Physical.jpg

I found that the readings from the pot would not give a proper zero at the low end and as this need numbers exactly between 0 and 255 inclusive I had to 'tidy up' the raw ADC readings with a bit of code.

Do not run your display too bright. I found a bit of burn in while trying to take the photographs.

Notice the use of the button to break out of the loop.

Tidy Up and Finish

364-373.jpg

I put the LED pin back to a normal state after using it for PWM

I hope this tutorial has been useful. Most of the routines can also be used with the smaller Pimoroni Pico Display screen.