This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| ir-for-mary [2023/11/18 12:29] – created admin | ir-for-mary [2023/11/18 14:29] (current) – admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Connect Hichi IR to the Pi Pico ====== | ====== Connect Hichi IR to the Pi Pico ====== | ||
| + | ===== Connection ===== | ||
| + | |||
| + | {{:: | ||
| + | |||
| + | |||
| + | |||
| + | ===== Ping-Pong string: Hello, Pico! ===== | ||
| + | |||
| + | Should return: | ||
| + | |||
| + | <code bash> | ||
| + | send data Hello, Pico! | ||
| + | Received: b' | ||
| + | </ | ||
| + | |||
| + | The Code: | ||
| <code python> | <code python> | ||
| - | # Bibliotheken laden | ||
| from machine import UART, Pin | from machine import UART, Pin | ||
| - | from time import | + | import |
| - | # UART0 initialisieren | + | # Define GPIO pins |
| - | uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1), bits=8, parity=None, | + | tx_pin |
| - | print(' | + | rx_pin |
| - | print() | + | |
| - | # UART1 initialisieren | + | # Initialize UART |
| - | uart1 = UART(1, baudrate=9600, | + | uart = UART(0, baudrate=9600, |
| - | print(' | + | |
| - | print() | + | |
| - | # Daten zum Senden | + | while True: |
| - | txData | + | |
| - | print(' | + | |
| + | print(' | ||
| + | uart.write(data_to_send) | ||
| - | # Daten senden | + | |
| - | uart0.write(txData) | + | |
| - | sleep(1) | + | |
| - | # Daten empfangen und ausgeben | + | |
| - | rxData | + | if uart.any(): |
| - | print('Daten empfangen:', rxData.decode(' | + | received_data |
| - | </ | + | # Process the received data here |
| + | print(" | ||
| + | |||
| + | # Wait for a short duration before the next iteration | ||
| + | utime.sleep_ms(500)</ | ||