rodzic
8fbf61ced1
commit
f0f802ef85
|
@ -0,0 +1,25 @@
|
|||
= Using UART on the Raspberry Pi Pico
|
||||
:xrefstyle: short
|
||||
|
||||
Send data from the UART1 port to the UART0 port.
|
||||
|
||||
== Other code to try
|
||||
[source.python]
|
||||
uart0 = UART(0) #opens a UART connection at the default baudrate of 115,200
|
||||
uart0.readline() #reads until the CR (\r) and NL (\n) characters then returns the line
|
||||
|
||||
|
||||
== Wiring information
|
||||
|
||||
See <<uart-wiring-diagram>> for wiring instructions.
|
||||
|
||||
[[uart-wiring-diagram]]
|
||||
[pdfwidth=75%]
|
||||
.Wiring two of the Pico's ports together
|
||||
image::pico_uart_example.png[]
|
||||
|
||||
== List of Files
|
||||
|
||||
A list of files with descriptions of their function;
|
||||
|
||||
uart.py:: The example code.
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 148 KiB |
16
uart/uart.py
16
uart/uart.py
|
@ -1,13 +1,15 @@
|
|||
from machine import UART, Pin
|
||||
import time
|
||||
|
||||
uart1 = UART(1, baudrate=9600, tx=Pin(8), rx=Pin(9), bits=8, parity=None, stop=1)
|
||||
uart1.write(b'UART on GPIO8&9 at 9600 baud\n\r')
|
||||
uart1 = UART(1, baudrate=9600, tx=Pin(8), rx=Pin(9))
|
||||
|
||||
uart0 = UART(0)
|
||||
uart0.write(b'UART on GPIO0&1 at 115200 baud\n\r')
|
||||
uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))
|
||||
|
||||
txData = b'hello world\n\r'
|
||||
uart1.write(txData)
|
||||
time.sleep(1)
|
||||
rxData = bytes()
|
||||
while uart0.any() > 0:
|
||||
rxData += uart0.read(1)
|
||||
|
||||
print(rxData)
|
||||
rxData += uart0.read()
|
||||
|
||||
print(rxData.decode('utf-8'))
|
Ładowanie…
Reference in New Issue