Skip to content

Commit 3b900f2

Browse files
authored
Create serial-read-write.py
Initial code for Circuit Playground Express Serial Communications guide
1 parent bb21868 commit 3b900f2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: CPX_Serial/serial-read-write.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import time
2+
import board
3+
import busio
4+
from adafruit_circuitplayground.express import cpx
5+
6+
uart = busio.UART(board.TX, board.RX, baudrate=115200)
7+
8+
while True:
9+
10+
data = uart.read(1) # read a byte
11+
12+
if data is not None: # Data was received
13+
14+
output = "%0.1f\t%d\t%0.1f\r\n" % (time.monotonic(),
15+
cpx.light, cpx.temperature)
16+
uart.write(output) # Print to serial
17+
18+
time.sleep(1.0)

0 commit comments

Comments
 (0)