Skip to content

A collection of Raspberry Pi Pico demos written in MicroPython

License

Notifications You must be signed in to change notification settings

tapiocode/raspberry-pi-pico-demos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Pico Demos

A collection of past beginner level Raspberry Pi Pico demos. Some experience with setting up electronics projects and understanding of programming concepts is assumed.

The demos:

  1. LED Array Sweeper – Create dynamic visual effects using an array of LEDs

  2. WiFi Ping-Over-HTTP – Send HTTP requests over the Internet by using a transceiver module

  3. Analog Radial Gauge – Indicate a reading by turning a needle attached to a stepper motor

  4. Digital Rotary Counter – Cycle through numbers on a digital rotary counter

  5. RGB LED Flame – Fire up an RGB LED with a cozy flickering flame effect

How To Run

First, pick a demo. Then:

  1. Build the project using the suggested components, or whatever parts you have at hand
  2. Examine the scripts (demo.py in particular) and evaluate whether they require altering in order to run properly
  3. Upload all necessary files from inside the demo directory to the root directory of the Pico
  4. Run demo.py, which is the main file for each demo

About The Demos

The demos are written in MicroPython 1.17. For downloads and information, see:

If you're new to the Pico, or building electronic projects, it may be a good idea to check out a few simpler guides provided by the Raspberry Pi Foundation (see links above) or any other source you like.

Building The Demos

You can pick and choose your own development tools as you please, but here's a few recommendations anyway:

The following items are common for all of the demos:

  • One Raspberry Pi Pico
  • A cable for communicating with Pico (typically Micro-USB)
  • A breadboard

Demos

LED Array Sweeper

The demo uses 10 LEDs to cycle through four different sequences in order.


Click for full size

Component Used in the demo
LEDs 10 (regular 5 mm, red)
Wires 22 × male/male

The setup in principle:

  • LED anode (long leg) connects to a GPIO
  • LED cathode (short leg) connects to GND

Basically, the number of LEDs in this project is limited by the number of available GPIOs. The program logic should work with any reasonable number of LEDs but if you use just a few of them you may have to fine-tune the variables to produce satisfactory results.

In the example, the GPIOs are 16, 17, 18, 19, 20, 21, 22, 26, 27, and 28.

Pin 18 (GND) grounds the bus strip.

Ideas

  • Arrange LEDs into a circle and use linear sequence for a swirly rotating effect
  • Set up white LEDs into a scattered pattern and use a slow random sequence for a twinkly stars effect
  • Embed the LED array running sweeper into the hood of a Pontiac Trans Am, see: https://en.wikipedia.org/wiki/KITT

WiFi Ping-Over-HTTP

The demo executes a simple HTTP GET request to a server over the Internet, then prints out details of the response.


Click for full size

Component Used in the demo
Serial WiFi Transceiver Module ESP8266-01 1
Wires 5 × male/female

Wiring configuration:

Transceiver Pico
UTXD UART0 TX (Pin 1)
URXD UART0 RX (Pin 2)
Vcc 3V3 (OUT) (Pin 36)
CH_PD 3V3 (OUT) (Pin 36)
GND GND (Pin 38)

For more information, see the manufacturer's wiki page: https://www.elecrow.com/wiki/index.php?title=Serial_WIFI_Transceiver_Module_ESP8266

Program Code

You need to fill in your wireless network name and password in main.py before the script can execute. It takes a few seconds to finish but its progress and the result can be observed in the console.

By default the script uses httpbin.org's service to get a response over the Internet but any other valid resource works just as well.

For some reason this setup seems somewhat unstable, which means subsequent runs don't reliably execute with the same result every time. So, if there is a problem getting a response you can just try again a few more times. You could also try adding some delay to the command calls.

Ideas

It should be easy to use the class already as it is for real projects. However, there are several other functions available on the transceiver module that can be easily added to the implementation.


Analog Radial Gauge

The demo turns the needle to briefly point at marked values one at a time, then retuns back and starts over.

See full size photo

The demo uses 28BYJ-48 5V stepper motor with a ULN2003 driver board, it should be easy to find these anywhere. For more information about the components turn to your preferred search engine.

Component Used in the demo
28BYJ-48 Step Motor 1
ULN2003 driver board 1
Wires 6 × male/female

Wiring configuration:

Driver board Pico
IN1 GP16
IN2 GP17
IN3 GP18
IN4 GP19
5–12V + VBUS (Pin 40)
5–12V - GND (Pin 38)

The makeshift gauge with needle (in the picture) was built with some paper, Blue Tac and a piece of wire.

In the demo the zero is wherever the needle points at in the beginning of execution, so you may have to reset the needle manually after each run.

Ideas

  • In various sensor data projects, replace your boring old LCD displays with crude but stylish "analog" contraptions
  • Evolve the demo into a sauna thermometer. For this, you may want to look into 1-wire digital thermometers such as DS18B20

Digital Rotary Counter

The demo rotates through a programmed sequence of numbers. This demo uses an SBC-OLED01 display, but it should also work with other devices compatible with the SSD1306 driver (copied from the MicroPython project).

Component Used in the demo
SBC-OLED01 display 1
Wires 4 × male/male

Wiring configuration:

Display Pico
SCL GP16
SDA GP17
Vcc 3V3 (OUT) (Pin 36)
GND GND (Pin 38)

The Numbers

The numbers seen on the display were built from Binary (raw) 1-bit PBM picture data, which was compiled into a source file, see numbers.py.

If you want to create your own numbers, you can use a free image editor GIMP, for example, to work on the files. You need to create a file for each number (10 in total), then use the script (see below) to compile the data.

In GIMP, when you have prepared your single number image, downgrade the palette by using ImageModeIndexed…, and select the 1-bit option. It may take a few attempts but when you're happy with the result, select Export…, use the suffix .pbm, and hit Export. When prompted, select Data formatting: Raw (not ASCII).

For reference, the demo directory contains:

Ideas

  • By adding buttons RESET and +1, you could actually make real use of this project in some situations
  • Adjust the speeds and rotation sequence to build a nailbiter lottery machine (again, do use buttons liberally)
  • You can actually fit a sixth digit in there by changing the parameters in demo.py, and if that's not enough just build a smaller set of numbers (see instructions above)

RGB LED Flame

Don't have an RGB LED? You can use a regular LED in GP13 (red wire) to experience the flickering effect. In fact, you can simply use the Pico's integrated led by changing the value of GPIO_RED to 25 on the line 11 in demo.py.

Component Used in the demo
Common Cathode RGB LED 1
Resistors 3 × 330 Ω
Wires 4 × male/male

Wiring configuration:

LED Pico
Red GP13 (with resistor)
Ground (longest leg) GND (Pin 18)
Green GP14 (with resistor)
Blue GP15 (with resistor)

In this demo, the RGB LED is covered with a small piece of plastic foam to diffuse the colors. You can achieve similar (or even much better) results by using some other materials and methods.

When run, the script creates a lengthy sequence of random values that's used to change the light intensity over time, which creates the flickering effect. The sequence is different every time the script is run, and repeats indefinitely.

Ideas

  • Should be straightforward to use as a safe replacement for an actual candle
  • Add a button to ignite and smother the flame with a smooth effect
  • Add a potentiometer "gas valve" to adjust the brightness

License

MIT License

About

A collection of Raspberry Pi Pico demos written in MicroPython

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages