Writting to UART on Pi Pico

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
GilbertGagne
 
Posts: 13
Joined: Mon Nov 09, 2020 12:53 pm

Writting to UART on Pi Pico

Post by GilbertGagne »

I am trying to send text to a Matrix Orbital LK-204-25 display. Cursor and line commands must preceed any text characters. For example, 0xFE and 0x58 clear the display and put the cursor at home position. The following is my test program: (Using THONY)

1 # Raspberry Pi Pico 1/18/2023
2 # Test Matrix Orbital Display LK-204-25 on UART0
3
4 from machine import UART, Pin
5
6 uart = UART(0, baudrate = 19200, tx = Pin(0))
7
8 uart.write(bytes([0xFE,0x58])) # clear display, cursor home
9 uart.write('Now is the time for ') # on line 1
10
11 print('Program exited')

# The program as written above works correctly but I would like to send cursor commands on the same line by
# combining lines 8 and 9.
# How can I express line 9 in the form: uart.write(buf, 'Now is the time for ')?
# What should "buf" look like? Everything I try reports errors on line 9.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Writting to UART on Pi Pico

Post by adafruit_support_carter »

Try:

Code: Select all

uart.write(bytes([0xFE,0x58]) + 'Now is the time for '.encode())

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”