HM-10/11 attempt for history

This commit is contained in:
Danny Staple 2022-06-22 20:08:54 +01:00
parent a1e868017a
commit c962c0bd6b
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import board
from digitalio import DigitalInOut
import time
import busio
led = DigitalInOut(board.LED)
led.switch_to_output()
# PICO UART pins? What am i not using?
uart = busio.UART(board.GP12,board.GP13,baudrate=9600)
while True:
data = uart.read(32)
if data is not None:
print(data)
data_string = ''.join([chr(b) for b in data])
if data_string=='1':
led.value = True
uart.write('on')
if data_string=='0':
led.value = False
uart.write('off')

View File

@ -0,0 +1,20 @@
import board
from digitalio import DigitalInOut
import time
import busio
import supervisor
led = DigitalInOut(board.LED)
led.switch_to_output()
# PICO UART pins? What am i not using?
uart = busio.UART(board.GP12,board.GP13,baudrate=9600)
while True:
data = uart.read(32)
if supervisor.runtime.serial_bytes_available:
value = input().strip()
print(f"Received: {value}\r")
uart.write(value.encode())
if data is not None:
print(data)