Microcontrollers are tiny integrated circuits (ICs) that you can program to perform various tasks. They have a processor, memory, and input/output pins (GPIO) to interact with the external world. From toys to cars, microcontrollers are everywhere in electronics.
The RP2040 is a powerful and versatile microcontroller built by the Raspberry Pi Foundation. This chip, based on the ARM architecture, is the heart of development boards like the popular Raspberry Pi Pico. We also utilize the RP2040 in Marble Pico board.
To unleash the potential of the RP2040, the Raspberry Pi Foundation created the Pico-SDK. This free and open-source software development kit (SDK) equips you with the tools and libraries needed to program the RP2040 in C and C++.
This chip name was provided by the Raspberry Pi foundation and is explained in the datasheet:
RP2040 has a dual M0+ processor cores, DMA, internal memory and peripheral blocks connected via AHB/APB bus fabric. It offers a variety of features for flexible development:
In short, the RP2040 packs powerful processing, flexible memory options, diverse communication options, and built-in peripherals, making it suitable for various development projects.
General-purpose input/output pins let you connect external components like LEDs, sensors, or buttons to your RP2040. You can configure them to be inputs (reading data) or outputs (sending data). The RP2040 provides 30 multi-function GPIOs controllable via software (C/C++ or MicroPython) for diverse functionalities beyond basic input/output.
In order to interface with the external environment, various electronic components are used, serving either as actuators (modifying the state of the external environment) or as transducers/sensors (influenced by the external environment and providing information to the microcontroller about various parameters).
Examples of actuators:
Examples of sensors:
LEDs - Light Emitting Diode - also called electroluminescent diodes - emit light when they are directly polarized. Not to be confused with light bulbs as they have radically different methods of operation.
LEDs can be used as indicator lights (often used in various appliances to signal that the appliance is on and doing something), or for illumination, in which case power LEDs are used. In the lab, LEDs are used to indicate the status of a pin.
Calculation of current limiting resistor To use an LED for the purpose of indicating the status of a pin (rather said to indicate the presence of voltage), the current through the LED must be limited. This can be done most simply by stringing a resistor with the LED.
An LED is designed to operate at a nominal current (ex: 10mA). The voltage drop at this current across low power indicator LEDs is given by the chemistry of the LED (this also gives the color of the LED). In the lab, since we are using such a low current LED, we can power it directly from the logic pins of the MCU.
If the MCU has a pin voltage of 3.3V, also noted as 3V3, to light up an LED with a nominal current of 10mA and a voltage drop of 2V we need a resistance of 130 Ω.
The simplest way for the user to interact with a MCU is through the use of buttons.
There are various ways to connect a button to the MCU, but these are the most used versions:
A breadboard is a rectangular board with a grid of holes that allows you to create temporary electronic circuits without soldering. The board typically has metal strips underneath the surface, connecting the holes in certain patterns. These patterns follow a standard layout, facilitating circuit building. Breadboards are reusable and provide a convenient way to prototype circuits quickly and make changes easily by rearranging components.
Jumper wires are flexible wires with connectors at each end, typically male connectors (pins) or female connectors (sockets). They are used to create electrical connections on a breadboard by plugging one end into a hole on the breadboard and the other end into another hole, forming a connection between the two points.
The RP2040, like most electronic components, has a datasheet (sometimes called a data sheet or spec sheet). This document is like an instruction manual for the chip, explaining its features and how to use it in your projects.
What's in an RP2040 Datasheet?
Keep in mind:
GPIO pins can be used as outputs (LEDs, motors, buzzers) or as inputs (buttons, sensors).
The R02040 has three peripherals that control the GPIO pins:
Wokwi is a web-based platform that allows you to simulate and prototype electronic circuits with microcontrollers. It provides a visual interface where you can drag and drop components, connect them with virtual wires, and write code to control their behavior. Wokwi currently supports popular microcontroller boards like: