Table of Contents

Connect Hichi IR to the Pi Pico

Connection

Ping-Pong string: Hello, Pico!

Should return:

send data Hello, Pico!
Received: b'Hello, Pico!'

The Code:

from machine import UART, Pin
import utime
 
# Define GPIO pins
tx_pin = 0  # GPIO pin for TX
rx_pin = 1  # GPIO pin for RX
 
# Initialize UART
uart = UART(0, baudrate=9600, tx=tx_pin, rx=rx_pin)
 
while True:
    # Send data
    data_to_send = "Hello, Pico!"
    print('send data', data_to_send)
    uart.write(data_to_send)
 
    # Wait for a short duration (adjust as needed)
    utime.sleep_ms(100)
 
    # Check for received data
    if uart.any():
        received_data = uart.read(uart.any())
        # Process the received data here
        print("Received:", received_data.decode('utf-8'))
 
    # Wait for a short duration before the next iteration
    utime.sleep_ms(500)