Learn how to control the GPIO pins on the Raspberry Pi Pico with MicroPython, and connect LEDs, motors, servos and sensors.
By Kevin McAleer, 3 Minutes
Watch the videos
This course has two companion videos. Part 1 covers pin types, digital I/O and PWM; Part 2 covers analog input, the communication buses, servos and sensors.
Overview
Welcome to Raspberry Pi Pico with MicroPython - GPIO Mastery! The Pico’s GPIO (General Purpose Input/Output) pins are how your code reaches out and touches the real world. In this course you’ll learn what each kind of pin can do, how to wire things up safely, and how to drive LEDs, motors, servos and sensors from MicroPython.
Course Content
The course is split into short sections:
Introduction to GPIO pins - pin types, pin numbering and voltage levels
Digital I/O and PWM - buttons, LEDs and motors
Analog I/O (ADC) - reading voltages, potentiometers and temperature sensors
UART, I2C and SPI - talking to other chips and modules
Servos and ultrasonic range finders - two robot favourites
Ground pins - why every circuit needs a common ground
Recap and review
Key Results
After completing this course, you will be able to:
Identify the different types of GPIO pins on the Pico and find them on the pinout
Use digital inputs and outputs, including pull-up resistors for buttons
Use PWM to fade LEDs, set motor speed and position servos
Read analog voltages with the ADC
Talk to other devices over UART, I2C and SPI
Keep your Pico safe by respecting its 3.3V logic level
A breadboard, jumper wires, a few LEDs and 220Ω resistors, and a push button
Optional parts for the later lessons: a 10kΩ potentiometer, a small DC motor and motor driver (L293D or DRV8833), an SG90 servo, an HC-SR04 range finder and a DS18B20 or DHT11 temperature sensor
Prerequisites
You should be comfortable writing simple Python programs. If you’re brand new to MicroPython, take Learn MicroPython - The basics first.
How the course works
Each lesson explains one idea, then shows real code you can run on your Pico. Most lessons end with a Try it yourself challenge and a quick quiz. Your quiz score and progress are saved in your browser and shown in the sidebar.
New keywords are highlighted inline like this.
This is a note
Important notes are highlighted like this
Another aside
Asides are also highlighted in sections, but in an alternative color
Comments