Raspberry Pi Pico H - Pico with Headers Soldered
The Raspberry Pi Pico H is a microcontroller board that is part of the Raspberry Pi family. It is a low-cost, highly capable device that is ideal for a wide range of applications, including IoT projects, robotics, and embedded systems development. The Pico H variant comes with headers soldered, making it easy to connect to breadboards, protoboards, or other development boards.
RP2040 microcontroller with 264KB of SRAM and 2MB of flash storage
Dual-core Arm Cortex-M0+ processor
Flexible I/O options, including GPIO, I2C, SPI, UART, and USB
Supports high-level languages such as Python and C/C++
Compatible with Raspberry Pi's official SDK and libraries
Example 1: Blinking an LED using MicroPython
In this example, we will use MicroPython to blink an LED connected to GPIO pin 25 on the Raspberry Pi Pico H.
```
import machine
import utime
# Set up GPIO pin 25 as an output
led = machine.Pin(25, machine.Pin.OUT)
while True:
# Set the LED high (turn it on)
led.value(1)
utime.sleep(1) # wait for 1 second
# Set the LED low (turn it off)
led.value(0)
utime.sleep(1) # wait for 1 second
```
Example 2: Reading Analog Input from a Potentiometer using C
In this example, we will use the C programming language to read an analog input from a potentiometer connected to ADC pin 26 on the Raspberry Pi Pico H.
```c
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/adc.h"
int main() {
// Initialize the ADC module
adc_init();
adc_select_input(0); // Select ADC pin 26
while (1) {
// Read the analog input value
uint16_t adc_value = adc_read();
printf("ADC value: %u
", adc_value);
sleep_ms(50); // wait for 50ms
}
Example 3: Communicating with a Uart Device using Python
In this example, we will use Python to communicate with a UART device connected to the UART pins (GPIO 0 and 1) on the Raspberry Pi Pico H.
# Initialize the UART module
uart.init(baudrate=9600, tx=0, rx=1)
while True:
# Send a string to the UART device
uart.write("Hello, UART device!")
utime.sleep_ms(50) # wait for 50ms
# Read data from the UART device
data = uart.read(10) # read up to 10 bytes
if data:
print("Received data:", data.decode())
```
Raspberry Pi Pico datasheet: <https://www.raspberrypi.org/documentation/microcontrollers/rp2040/datasheet.pdf>
Raspberry Pi Pico SDK documentation: <https://datasheets.raspberrypi.org/pico/rp2040-sdk-docs/>
MicroPython documentation: <https://docs.micropython.org/en/latest/>
Note: These code examples are for demonstration purposes only and may require modifications to work with your specific setup. Always refer to the official documentation and datasheets for the Raspberry Pi Pico H and any connected devices for accurate and up-to-date information.