- # CircuitPython Demo - USB/Serial echo
- import board
- import busio
- import digitalio
- import time
- led = digitalio.DigitalInOut(board.D13)
- led.direction = digitalio.Direction.OUTPUT
- uart = busio.UART(board.TX, board.RX, baudrate=9600,timeout=0)
- c=0
- seq = []
- seq_string=""
- count=0
- for x in range(0,3):
- print("Boot...")
- led.value=True
- time.sleep(0.5)
- led.value=False
- time.sleep(0.5)
- while True:
- led.value = True
- c = uart.read(1)
- #if (c!=None):
- if ( c != b'' and c !=None ):
- #print(str(c))
- #print("c="+str(c))
- #print("char="+chr(c[0]))
- seq.append(chr(c[0])) #convert from ANSII
- if c == b'\n':
- data_string=''.join(seq).strip()
- print("Line " + str(count) + ': ' + data_string)
- seq = []
- joined_seq=""
- seq_string=""
- count=count+1
- #time.sleep(1)
- led.value = False
- #time.sleep(1)
Untitled
Posted by Anonymous on Wed 21st Nov 2018 01:10
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.