Jump to content
Electronics-Lab.com Community

Recommended Posts

 
Couple of months ago, I bought a "Raspberry Pi Pico" to get some hands-on experience of it and to create some amazing projects using it. But since then, it has just been sitting on my desk, collecting dust. Today after a very long wait, I finally have decided to create a short video tutorial to show you guys how to get started with the Raspberry Pi Pico.
 
 

Topics Covered 

AVvXsEgIlYf52EAoFIWEUYplU_n1L5twEW4Iw9uZyTtNZNgeUVOJOsqy960qtcCRSsw0Vb1gVZxd1ahH6TNZB1S16td07gqlq6Jm5QOJtfvJwABT4u1wEhepWfDjXLaqbU0hv54Wr09KJwbVyGn2mMS_4ufEWNNe2T2xRnFB-kqasiqXzuOEmwA8qp6dS8LD=w640-h360
In this tutorial, I am going to discuss:
1. What is a Raspberry Pi Pico?
2. The technical specifications of the board
3. How to program Pico using C/C++ and MicroPython
a. Programming Raspberry Pi Pico using "Arduino IDE"
i.   Preparing the Arduino IDE
ii.  Loading the Blink Example
iii. Demo
b. Programming Raspberry Pi Pico using "Tonny Python IDE"
i.   Installing MicroPython on Pico
ii.  Installing Tonny Python IDE
iii. Loading the Blink Example
iv.  Demo
4. Difference between Raspberry Pi Pico and Arduino
5. Advantages and Disadvantages of this board
 
 
 

What is Raspberry Pi Pico?

AVvXsEg-2uVAQZfQle1xlwxhwHh7tHxpnvPnmX9A0Y4LSZU0jrxyaue63D_wv9kQodU8jxFmdGudCAn3EPB8cB8o1YZ5dx1FNlN-tovdaspadxVJ5cCA-Q_LDO4K0KsvZDRCTsyy-xwfABkp9YPYJ-lTyx-cGODQihTBKmP00e-_AT9RHyAPA6TWvaor2t-C=w640-h360
 
Raspberry Pi Pico is a low-cost microcontroller. It can be used to control other electronic modules and sensors same as any other microcontroller.
Pico is not a Linux single board computer, rather it is a microcontroller like Arduino. Since, its a microcontroller it doesn't come with all the overheads that a computer brings and hence consumes much less current. actually it is more like Arduino than Raspberry Pi.
Pico is not a rival of Raspberry Pi Zero, it actually can work in conjunction with the regular Pi's.
Pico is breadboard friendly and has 40 GPIO pins operating at 3.3v (20 on each side). It has a Dual-Core ARM Cortex M0+ processor. Pico's brain - the RP2040 microcontroller chip is designed by Raspberry Pi in United Kingdom. 
 
AVvXsEjWJUMrXy6OcBRJtaxdvgeRnTeFm4oUGOgvp9uOyDYAgC7ciGz_MXFRHfq4wKjlVK1W8p21iJZFJKJnGEGzBSMdtrccccD3bSh4vHjvfhymOUcWVAeG6kTdppSmChfg5Fca1iOlSslahIOK7RDNSMQiuQQm1smOdJw3lIji1qqnW0UNVep-fvhvzsIp=w640-h360
 
It can be powered either via the micro USB port, or via the VSYS GPIO pin by providing voltage between the range of 1.8V to 5.5V.
 
 
 

Technical Specifications of Pico

AVvXsEjZiKWuuviL8kSttJ2yjvs7BHXP-R7K2jEMklaBn6H9PWsPsx1I1x6yE65mTe5_dVl6rZRMN9m-fsBZSBR5XArc7SVlNk5-6X3f_udcR_BVUVQo346vWbJB02gilOp9R0gaw5PIwnj5ZL28fWUvrUJQc2ojI6i6Db6fhPpsAqKRlatxjuXCT79pVCMO=w640-h360
 
Raspberry Pi Pico is absolutely different from all other Raspberry Pi models. Pico is one of the first microcontrollers to use the RP2040 "Pi Silicon" processor. It is a custom "System on Chip" (SoC) developed by the Raspberry Pi team in UK which features a dual core Arm Cortex M0+ processor running at 133 MHz, 264KB of SRAM and 2MB of flash memory for storing files on it. 
 
Specifications:
- Microcontroller: RP2040 designed by Raspberry Pi in the UK
- Processor: Dual-Core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz
- Input power: 1.8 - 5.5 V DC
- Operating temperature: -20°C to +85°C
- Dimensions: 51.0 x 21.0 mm
- Onboard Sensors: Temperature Sensor
- Memory: 264KB of on-chip internal SRAM and can support up to 16MB of off-chip Flash
          2MB on-board QSPI Flash (Adafruit's Feather RP2040, features 16MB of storage)
 
- GPIO: It has 40 GPIO through-hole pins also with edge castellation
- 26 × multi-function 3.3V GPIO pins, which includes 3 analogue inputs (The Analog inputs is something other Raspberry Pi's lack. They use variable voltages to connect to devices like a potentiometers, joystick or a LDR) 
- 2  × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels
- 8  × Programmable I/O (PIO) state machines for custom peripheral support that can offload many kinds of timing-critical processes from the CPU 
 
- Other Features:
- 1 × Contains 1 × USB 1.1 controller and PHY, with host and device support
- Accurate clock and timer on-chip 
- Low-Power sleep and dormant modes
- Accelerated integer and floating-point libraries on-chip
- Works with Windows, Mac, Linux machines and Raspberry Pi Computers
- Provides drag-and-drop programming using mass storage over USB
 
AVvXsEjDPtPx9zT6C_9cIJ_6I17g1gILO3Sw65qpT50eAR0KoS1fBFKUsxHN-2lcLoWks3P4OmOv0_hS7p-9tm8GDHq4lOfv9JijgJSznD22MCugk-TcI-4IlfDTYoO5UH9Fv-vDVnCu6W_QKeKQkfQFScMNQjVe03RlCkWImBcLOt3bIvs0LYj8e8Hbru4X=w640-h360
 
The one biggest disadvantage of the Raspberry Pi Pico is that there is no WiFi or Bluetooth on it. ESP32 and ESP8266 which you can buy for similar price comes with WiFi and Bluetooth (ESP32). Surely we can add wireless connectivity via external components, however that would require a little bit more knowledge and experience to get it working.
 
AVvXsEi5WbyaHRpbeFZ7AZr1RFrNkl9yY0FAcGTG0-ZzAxJqrtZrZNibjhmAKlc7qJEuevPSC-9_igXC6QeG-6BzG3G_qbrJ96DXmf2U0BLjIpu1wVJ2Yt5dI8lvy8S51H-ElxGxjcvg3ck7QMDbyO22GGu9x_eaRVYvxM7vxXhAAIsFNYNy6AcJl3EZMQGg=w640-h360
 
Since Pico is not a computer, we need to write our codes on a different machine using an external application and then "flash" the code onto the microcontroller over USB.
 
Pinout Diagram: 
Here is the top view of the pinouts on the Raspberry Pi Pico. The pin-labels are on the bottom side of the board.
 
AVvXsEgEdWLWjgMUp2MV1vP-0wQKLuMi2Yo5SvyOSVwjIXnGhJOqZRGY8ZlqO9RzI3TPkSp5fwFQBvSXNPFxMcfq3cfU9SJ5WO6iGIwdITh0yCryuqmb-lWCvX8Fcd7wvYdQv5vUaZH5VMVwaoJ3vzvp3QtR7HskTW-TrYZ0lfA2Xq3sUEytMUjauMDrXdxq=w640-h360
 
 
 

How to program Pico using C/C++ and MicroPython

AVvXsEiAdohjscXZbzi2kE1BlyofWOvw3Pug214uH92uxsiTuIIdvuJSJW4dW3XjCMG4y-8zIa6es3fgk_QEaHko7z8faUzTtO0NA7VLU5JyihTlvu3kA8Q-EEekFcs5g-Cp7gRKUWldBnN1WWjJzxr0RMoVkxBuDltM8HwI7Vf0f3jKm4exeABCrokO23QZ=w640-h360
 
Pi Foundation officially supports MicroPython and C/C++, however high-level programming language like CircuitPython (A fork of MicroPython created by Adafruit), and Drag and Drop Python Editor like Pico Piper which adds further enhancements and can be used to program the Pico boards.
 

Programming Raspberry Pi Pico using Arduino IDE

Python and C/C++ are both great for programming Picos. However, being able to program a Pico just like an Arduino would help us to integrate the Pico into the Arduino ecosystem. One of the best reasons to do this is because of the availability of libraries to integration of modules, sensors, and other complex stuff without having to write the entire code from scratch.
 

i. Preparing the Arduino IDE

AVvXsEjXVSDRqv665GILFlDn0P5b6aoFEOa7mxPKDDGKDWewX7W2BkFUGq98EideOtWCJpTPlKpqkiUgOKB8Ca5XE5v3guU3PwCPi04CmtS2zH73gcHIT1F2sPXygnmVoD24FEB_85ORhL-OXlJOBAlUscqzpj3tL8dCykdh968NDy8DUuS3bn1fU4E_49GQ=w640-h360
 
To start, let go to Tools > Boards > Boards Manager and search for "Pico", select "Arduino Mbed OS RP2040 Boards" and hit the install button.
Connect the micro USB cable to the Pico and then press and hold the "BOOTSEL" button before plugging the USB cable into the computer. Release BOOTSEL once the drive RPI-RP2 appears on your computer.
Now, go to Tools > Port and you will now be able to see the number of the COM Port.
 

ii. Loading the Blink Example

Go to Files > Examples > Basics > Blink and click on Upload, this will load the code to the Pico board.
 

iii. Demo

AVvXsEgY4EaVY2PYf6Zze4wJRdEyBELluXaOv2DUWcUoqSqxZSziXQBMEy9z7mHF1zb9iXg7PDPC-rO28T1nDI2Gb0W1NErSI8V7ufHNRT_kn16XLS7cm4-u7zk0vbdz6aVsow_akstyFfViswtX8x2rGZwyS2K-UNDmH7StOFTpZv4MTVpfdBZpHP44yqY4=w640-h360
 
After the IDE finished uploading the code, you will see the Pico's onboard LED blinking.
You can now use your Pico like an Arduino and program it using the Arduino IDE.
 
 
 

Programming Raspberry Pi Pico using Tonny Python IDE

You can program your Pico using MicroPython by connecting it to a computer via USB and then dragging and dropping files to it.
 

i. Installing MicroPython on Pico

AVvXsEg0XWD-s8pzwZr6mYeZa_aTSvn7HXxzPZcudD6rkhzStXP29Okbyh5u3L27IBIu1ZHzpb1wWqbmCXDpIJBUkMHFA8Phf76ejBbc96Eu9LivTNB3TQJqJFqPu7IFuoYMLhOwrj1PhtRvdHgzuzvjbFFus98TpiUWJnPpW3ZRnrRiwObN_XA7T2cah0RW=w640-h360
 
Installation of MicroPython on Pico requires a "UF2" file to be copied onto it. A UF2 file is a "binary data file" which contains a program that can be transferred from a PC to a microcontroller, such as an Arduino or Pico circuit board. 
To load MicroPython on Pico:
1. Download "MicroPython UF2 file" from the link provided in the description below.
2. Connect the micro USB cable to the Pico and then press and hold the "BOOTSEL" button before plugging the USB cable into the computer. Release BOOTSEL once the drive RPI-RP2 appears on your computer.
3. Drag and drop the UF2 file onto the RPI-RP2 volume. 
4. Your Pico will reboot. That's it, you are now running MicroPython on your Pico.
 

ii. Installing Tonny Python IDE

To write code and save files to Pico we are going to use the "Thonny Python IDE". Thonny comes with built-in Python 3.7, so just one simple installer is what you need to learn programming. To get started:
1.  Download and install "Thonny" free from the Thonny website for your version of OS. The website's link is in the description below.  
Note: If you are running "Raspberry Pi OS" then Thonny is already installed on it, but may need to update it to the latest version
 
sudo apt update && sudo apt upgrade -y

2. Connect the Raspberry Pi Pico to your computer. Then, in Thonny go to Tools > Options and click on the "Interpreter" tab. From the interpreter dropdown list select "MicroPython (Raspberry Pi Pico)". The port dropdown menu can be left to "automatically detect the Pico". Click "OK" to close. 
3. A Python Shell called "REPL" (Read, Eval, Print, Loop) will popup to show that the Pico is connected and working.
 

iii.  Loading the Blink Example

1. Click in the main editor pane of Thonny and enter the following code to toggle the onboard LED.
 
from machine import Pin, Timer
led = Pin(25, Pin.OUT)
timer = Timer()


def blink(timer):
led.toggle()

timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink)
2. Click the "Run" button to execute the code. 
3. Thonny will ask whether you want to save the file on "This computer" or the "MicroPython device". Choose "MicroPython device". Enter "blink.py" as the file name. Make sure you enter ".py" as the file extension so that Thonny recognizes it as a Python file.
 

iv. Demo

AVvXsEiR_rIEBmqfZ7Ylt2rVc4xazmGBy_pVWH5vJCbfpfgp--UMhpoO7F7TXolgHZY51btpaKJIVokYtF6u0mZUuSQqTiXg0iJCW4RuQgYRbDj_6NEalzpnD0x_SGRXb3jQK6d6kNaw0kSmYtI9j8axgxzQ5T6jNUWtdf2nZ2vN3yejoTjLqV2BgD5KfeBX=w640-h360

You should now see the onboard LED switching between on and off until you click the Stop button.
 
 
 

Difference between Raspberry Pi Pico and Arduino

AVvXsEgfoityInGJWT7fPyCpGsfDPq9Jif2bMgZ50ucGp473z-ePHxy8Gkt0acFjZR3hAfQf_8jy_Lu1JK5TYKwaohGqzyH7TzR5JSJG-AxeugPJQMR_IUdgC-S2c-7VGjwIxO2RTX0Imj_XXQowxBraUlSacw6r1jko0joeeWzjo9ME75d938GbKvAi7ngW=w640-h360
* Before Raspberry Pi Pico, Raspberry Pi has always been know for their single board computers. 
  However, in 2021 Raspberry Pi Foundation stepped a few steps forward and launched the Raspberry Pi Pico giving a head-to-head challenge to Arduino and all other board based microcontrollers.
* Arduino was first introduced in 2005 and since then Millions of Arduino Units have been sold in the market. Compared to that, the response Pico received after its initial launch in 2021 is absolutely mind-blowing.
* Both units are made for automating applications that don’t involve human intervention. 
* Pico can be used alone or in combination with Arduino for Automation and AI purposes.  
* Both modules are different in terms of power consumption, value, functionality, and price.
* Pico boards come unsoldered however Arduino comes pre-soldered or unsoldered.
* Pico module supports MicroPython and C/C++, while Arduino codes are written in C/C++ using Arduino.IDE.
 
AVvXsEhCgrhbHAmbO1iUV681ly4uZKN6VY8_2I1qeTgvvmEtPwR9vkmjJO0D56dkpdFdEeMHyzljLCp7waLPVflylvSyPJj5amhHxheFwxNQE0CZjfVyENvVxG5A1crVhm-lM_a87_yg6w2YnL8Uf7dJnQzlQWDUSton8UN9X6D87p9tOBV8GcyR5k2k0-qf=w640-h360

So which one to go for… Pico or Arduino?
 
 

Advantages and Disadvantages

AVvXsEiEqrWWQgeeH5vKJwCKZuZ8Bs4qgHLJ-0SPwzu70F-kxI8hGTgaNM2eh7PAQirRGw0_S7OXEu0WRJEVxZ_fEfFSv8U0SWRgutIIY_YS-7HrJ7xc-dij3N5g-7OD3WBP5Ij3bend2gJfJi219Yw9FNtcMWs8VQN50m01_689r8e0VWPb2y3HzINfvSVi=w640-h360

Now lets have a look at the Pros and Cons of this microcontroller board.
Advantages:
* Raspberry Pi Pico is cheap, very small, and easy to use microcontroller
* Pico is a dual core device coupled to a high-performance bus matrix, which means its both cores can give you the full performance concurrently
* Pico consumes very low power
* Pico is a breadboard friendly 
* Pico can be programmed using C/C++ and MicroPython
* Pico can be programmed using Arduino IDE
* Pico has 26 × multi-function 3.3V GPIO pins (23 Digital + 3 Analogue)
* Pico comes with 8 x Programmable IO (PIO) and 2 x Analog Inputs
* Pico boots quickly and doesn’t require a safe shutdown
 
Disadvantages:
* Pico completely lacks WiFi and Bluetooth without any add-ons
* It lacks the GPIO markings on the top side of the board
* The board comes unsoldered so you will have to solder the header pins or surface mount it to use it in your project
* GPIO pins are 3.3V, which could be seen as a disadvantage, however devises designed for 5V can still be used with 3V via a voltage divider or a logic level converter.
* Pico still uses micro-USB port. While many other microcontrollers have moved to USB-C, Pico is still coming with the  micro-USB port
 
AVvXsEgcm9ZJSOPBmh4r6A86vCQhVYb2BfPTv09l7uC9Nal-6W6gA38NgEJVJBj1X1LaeQJtaDdyhq849uYXZMEXlaErQ3AE-eSnp4YVJvwnHuXJkhLSScQ1MYwPyCyzo6q4gLSocjzo_a1bCERzI4ei8UI28gG8fFaIaswYBc0cUj9AgX-fmGeoo8s4PYS6=w640-h360

If you have a Windows, Apple, Linux or even a Raspberry Pi, then you are already well in your way to program the small, cute, and gorgeous Raspberry Pi Pico in your next project. I bet, there must be a lot of project ideas going in your mind, so get your supplies and start coding. And, what are you waiting for???
 
 
 

Thanks

 
Thanks again for checking my post. I hope it helps you.
If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3
 
 
 
Other Resources:
 
 
Thonny website : https://thonny.org/
 
 
Support My Work:
BTC:  1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp
LTC:  MQFkVkWimYngMwp5SMuSbMP4ADStjysstm
DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st
ETH:  0x939aa4e13ecb4b46663c8017986abc0d204cde60
BAT:  0x939aa4e13ecb4b46663c8017986abc0d204cde60
LBC:  bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2
 
Thanks, ca again in my next tutorial.
Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...