Basic Input and Output With The Raspberry Pi Pico

A cheerful orange octopus adjusts wires on a breadboard with a Raspberry Pi Pico, potentiometer, and glowing LED beneath the text Basic Input / Output On the Pico.

This section follows the tutorials that are defined on the Raspberry Pi page with some photos of the circuits as they look in reality.

Turning the LED on and off

Type the following into the Shell at the bottom of the screen. Type each line in turn then press return.

 When it is typed in it will appear like this….

The LED should illuminate on the Pico board.

Then to turn it off again

The LED will go off, finally it can also be made to blink.

 and the LED will flash.

Using inputs and outputs

You might find the following resources useful for this project.

Connect the circuit as shown with the resistor connected to GP15 on the Pico via a 50-330 ohm resistor. The resistor is required to limit the current to the LED and prevent damaging the LED.

The longest leg must be connected to pin GP15 and the shortest leg to the negative rail.

Now, enter the following into the editor, after firstly clicking new.

Paste the following into the editor then click the green “go” button.

The LED should now start blinking

If it doesn’t work then check that everything is connected correctly.

Controlling the LED with a Switch

Next, connect the button as show. It is worth noting that the connections to buttons and switches can change. Depending upon the one you have it might be different to the one shown on the Raspberry Pi website.

When I connected the circuit the LED was constantly on, so I had to wire it like this because the connections to the button was slightly different.

Type the following into the Shell and confirm that pressing the button turns the LED on and off.

Pulsing LED

The LED can cycle from on to off following a button press using the following code:

When the button is pressed the LED will start to cycle through brightness levels.

Changing the Brightness of the LED

Changing the brightness of the LED can be achieved by setting the brightness level. The following code cycles indefinitely setting the brightness level every second.

Controlling the LED using an analogue input

You might find the following resources useful for this project.

Connect the circuit as shown below:

Which should look like this:

Type the following in:

Rotate the shaft of the potentiometer and the brightness of the LED should change.

Main Topic

The Raspberry Pi Pico

Raspberry Pi Pico on a breadboard with sensors and jumper wires arranged neatly on a desk, ready for an electronics project.

Raspberry Pi Pico is an affordable, efficient microcontroller offering flexible GPIO, strong performance, and versatile hardware features for beginner electronics projects.

Other Tutorials in this Topic

Cartoon Raspberry Pi Pico on a breadboard with glowing LED and wires beside a computer screen showing the Thonny picozero plugin installation.

Getting Started With The Raspberry Pico

Getting started guide showing how to set up a Raspberry Pi Pico on a breadboard and install…

A cheerful cartoon duck turns a control dial beside a spinning motor while an oscilloscope displays a squarewave showing PWM motor control.

Pico Motor Control Using the L9110 Control Board

A tutorial showing how to control a motor using PWM modulation to varying the speed of a…

Cartoon computer and Raspberry Pi Pico shout echo into a glowing cave with bold title Using Bluetooth On The Raspberry Pico.

Using Bluetooth on the Raspberry Pico

The article explains how to use Bluetooth Low Energy on the Raspberry Pi Pico, set up BLE…

Small educational robot uses ultrasonic sensor to navigate obstacles like cones and boxes while moving through a bright indoor course

Getting Started with an Ultrasonic Sensor Module on…

Beginner guide explaining how an ultrasonic sensor module works with Raspberry Pi Pico to measure distance using…

Cartoon robot spins happily while IMU detects z-axis rotation with arrows screens and motion lines in colorful laboratory scene background

Using the MPU6050 Gyro With Raspberry Pi Pico

The article explains how the MPU6050 IMU measures motion and rotation and communicates with microcontrollers using the…

Cartoon LCD on breadboard shows Hello from Tinkimo heart while silly banana sparks and googly eyed hammer watch Pico project

Using an LCD with the Pico

Beginner friendly guide explains using an LCD with the Raspberry Pi Pico for wiring, control signals, and…

Raspberry Pi Pico on breadboard drives LCD showing Hello message surrounded by colourful wires LEDs creating playful beginner electronics scene

Controlling an ST7789 Display With a Raspberry Pi…

Beginner guide explains using an ST7789 LCD with a Raspberry Pi Pico to create simple colourful display…