Skip to content

Commit f0f802e

Browse files
authored
UART example update and README
First attempt
1 parent 8fbf61c commit f0f802e

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

uart/README.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
= Using UART on the Raspberry Pi Pico
2+
:xrefstyle: short
3+
4+
Send data from the UART1 port to the UART0 port.
5+
6+
== Other code to try
7+
[source.python]
8+
uart0 = UART(0) #opens a UART connection at the default baudrate of 115,200
9+
uart0.readline() #reads until the CR (\r) and NL (\n) characters then returns the line
10+
11+
12+
== Wiring information
13+
14+
See <<uart-wiring-diagram>> for wiring instructions.
15+
16+
[[uart-wiring-diagram]]
17+
[pdfwidth=75%]
18+
.Wiring two of the Pico's ports together
19+
image::pico_uart_example.png[]
20+
21+
== List of Files
22+
23+
A list of files with descriptions of their function;
24+
25+
uart.py:: The example code.

uart/pico_uart_example.png

148 KB
Loading

uart/uart.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from machine import UART, Pin
2+
import time
23

3-
uart1 = UART(1, baudrate=9600, tx=Pin(8), rx=Pin(9), bits=8, parity=None, stop=1)
4-
uart1.write(b'UART on GPIO8&9 at 9600 baud\n\r')
4+
uart1 = UART(1, baudrate=9600, tx=Pin(8), rx=Pin(9))
55

6-
uart0 = UART(0)
7-
uart0.write(b'UART on GPIO0&1 at 115200 baud\n\r')
6+
uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))
87

8+
txData = b'hello world\n\r'
9+
uart1.write(txData)
10+
time.sleep(1)
911
rxData = bytes()
1012
while uart0.any() > 0:
11-
rxData += uart0.read(1)
12-
13-
print(rxData)
13+
rxData += uart0.read()
14+
15+
print(rxData.decode('utf-8'))

0 commit comments

Comments
 (0)