HM-10/11 attempt for history
This commit is contained in:
@@ -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')
|
||||||
@@ -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)
|
||||||
Reference in New Issue
Block a user