1. Chapter 1 LED (Important)

Note

Raspberry Pi Pico, Raspberry Pi Pico W and Raspberry Pi Pico 2 only differ by one wireless function, and are almost identical in other aspects. In this tutorial, except for the wireless function, other parts use Raspberry Pi Pico’s map for tutorial demonstration.

This chapter is the Start Point in the journey to build and explore Pico electronic projects. We will start with simple “Blink” project.

1.2. Project Blink

In this project, we will use Raspberry Pi Pico to control blinking a common LED.

1.2.1. Component List

1.2.2. Component List

Raspberry Pi Pico x1

Chapter01_08

USB Cable x1

Chapter01_09

Breadboard x1

Chapter01_10

LED x1

Chapter01_11

Resistor 220Ω x1

Chapter01_12

Jumper

Chapter01_13

1.2.3. Component Knowledge

1.2.3.1. LED

An LED is a type of diode. All diodes only work if current is flowing in the correct direction and have two Poles. An LED will only work (light up) if the longer pin (+) of LED is connected to the positive output from a power source and the shorter pin is connected to the negative (-). Negative output is also referred to as Ground (GND). This type of component is known as “Polar” (think One-Way Street).

All common two-lead diodes are the same in this respect. Diodes work only if the voltage of its positive electrode is higher than its negative electrode and there is a narrow range of operating voltage for most all common diodes of 1.9 and 3.4V. If you use much more than 3.3V the LED will be damaged and burn out.

../../../_images/Chapter01_14.png

Note

LEDs cannot be directly connected to a power supply, which usually ends in a damaged component. A resistor with a specified resistance value must be connected in series to the LED you plan to use.

1.2.3.2. Resistor

Resistors use Ohms (Ω) as the unit of measurement of their resistance (R). 1MΩ=1000kΩ, 1kΩ=1000Ω.

A resistor is a passive electrical component that limits or regulates the flow of current in an electronic circuit.

On the left, we see a physical representation of a resistor, and the right is the symbol used to represent the presence of a resistor in a circuit diagram or schematic.

../../../_images/Chapter01_15.png

The bands of color on a resistor is a shorthand code used to identify its resistance value. For more details of resistor color codes, please refer to the appendix of this tutorial.

With a fixed voltage, there will be less current output with greater resistance added to the circuit. The relationship between Current, Voltage and Resistance can be expressed by this formula: I=V/R known as Ohm’s Law where I = Current, V = Voltage and R = Resistance. Knowing the values of any two of these allows you to solve the value of the third.

In the following diagram, the current through R1 is: I=U/R=5V/10kΩ=0.0005A=0.5mA.

../../../_images/Chapter01_16.png

WARNING: Never connect the two poles of a power supply with anything of low resistance value (i.e. a metal object or bare wire) this is a Short and results in high current that may damage the power supply and electronic components.

Note

Unlike LEDs and Diodes, Resistors have no poles and re non-polar (it does not matter which direction you insert them into a circuit, it will work the same)

1.2.3.3. Breadboard

Here we have a small breadboard as an example of how the rows of holes (sockets) are electrically attached.

The left picture shows the way to connect pins. The right picture shows the practical internal structure.

../../../_images/Chapter01_17.png

1.2.3.4. Power

In this tutorial, we connect Raspberry Pi Pico and computer with a USB cable.

../../../_images/Chapter01_18.png

1.2.4. Circuit

First, disconnect all power from the Raspberry Pi Pico. Then build the circuit according to the circuit and hardware diagrams. After the circuit is built and verified correct, connect the PC to Raspberry Pi Pico.

CAUTION: Avoid any possible short circuits (especially connecting 3.3V and GND)!

WARNING: A short circuit can cause high current in your circuit, create excessive component heat and cause permanent damage to your hardware!

Schematic diagram

Chapter01_19

Hardware connection.

If you need any support, please contact us via: support@freenove.com

Chapter01_20

Note

To help users have a better experience when doing the projects, we have made some modifications to Pico’s simulation diagram. Please note that there are certain differences between the simulation diagram and the actual board to avoid misunderstanding.

1.2.5. Code

Codes used in this tutorial are saved in “Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi_Pico/Python_Codes”. You can move the codes to any location. For example, we save the codes in Disk(D) with the path of “D:/Micropython_Codes”.

1.2.5.1. 01.2_Blink

Open “Thonny”, click “This computer” -> “D:” -> “Micropython_Codes”.

../../../_images/Chapter01_34.png

Expand folder “01.2_Blink” and double click “01.2_Blink.py” to open it. As shown in the illustration below.

../../../_images/Chapter01_35.png

Make sure Raspberry Pi Pico has been connected with the computer. Click “Stop/Restart backend”, and then wait to see what interface will show up.

../../../_images/Chapter01_36.png

Click “Run current script” shown in the box above, the code starts to be executed and the LED in the circuit starts to blink. Press Ctrl+C or click “Stop/Restart backend” to exit the program.

../../../_images/Chapter01_37.png

Note

This is the code running online. If you disconnect USB cable and repower Raspberry Pi Pico, LED stops blinking and the following messages will be displayed in Thonny.

../../../_images/Chapter01_38.png

1.2.5.2. Uploading code to Raspberry Pi Pico

As shown in the following illustration, right-click the file 01.2_Blink.py and select “Upload to /” to upload code to Raspberry Pi Pico.

../../../_images/Chapter01_39.png

Upload main.py in the same way.

../../../_images/Chapter01_40.png

Disconnect Raspberry Pi Pico USB cable and reconnect it, LED on Pico will blink repeatedly.

Note

Codes here is run offline. If you want to stop running offline and enter Shell, just click “Stop” in Thonny.

../../../_images/Chapter01_41.png

If you have any concerns, please contact us via: support@freenove.com