Introduction: Raspberry Pi Pico & Pico Explorer Workout
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
Step 1: Wire Up
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
Attachments
Step 2: Basic Boilerplate and Procedures
This sets up the display and has routines to clear the screen to black and write titles for each section of code.
Step 3: Lines and Boxes
These routines provide vertical and horizontal lines, lines between two points and hollow rectangles.
Step 4: Alignment and Circles
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.
Step 5: Bar Graph and User Defined Characters (small)
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.
Step 6: Larger Defined Characters
This routine draws the predefined characters at size 3.
Step 7: Basic Stuff
Here we start the main program showing lines, circles, a box and predefined characters at two sizes
Step 8: Character Set
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.
Step 9: A Load of Lines
Lines at any angle and drawn pretty quickly.
Step 10: Sine and Cosine Curves
Notice the speed difference with display.update() inside and outside the loop
Step 11: Text on a Path
Pretty easy to do
Step 12: Scrolling Text on a Path - Setup
Step 13: Scrolling on a Path - the Loop
I was impressed by the speed the pico and display managed this. There is a great deal going on.
Step 14: Physical Computing - Potentiometer, LED With PWM, Bar Graph and Button
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.
Step 15: Tidy Up and Finish
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.