pastebin - collaborative debugging tool
python.kpaste.net RSS


Untitled
Posted by Anonymous on Wed 21st Nov 2018 01:10
raw | new post

  1. # CircuitPython Demo - USB/Serial echo
  2.  
  3. import board
  4. import busio
  5. import digitalio
  6. import time
  7. led = digitalio.DigitalInOut(board.D13)
  8. led.direction = digitalio.Direction.OUTPUT
  9.  
  10. uart = busio.UART(board.TX, board.RX, baudrate=9600,timeout=0)
  11.  
  12.  
  13. c=0
  14. seq = []
  15. seq_string=""
  16. count=0
  17. for x in range(0,3):
  18.     print("Boot...")
  19.     led.value=True
  20.     time.sleep(0.5)
  21.     led.value=False
  22.     time.sleep(0.5)
  23.  
  24.  
  25. while True:
  26.     led.value = True
  27.     c = uart.read(1)
  28.     #if (c!=None):
  29.     if ( c != b'' and c !=None ):
  30.        #print(str(c))
  31.        #print("c="+str(c))
  32.        #print("char="+chr(c[0]))
  33.        seq.append(chr(c[0])) #convert from ANSII
  34.        if c == b'\n':
  35.            data_string=''.join(seq).strip()
  36.            print("Line " + str(count) + ': ' + data_string)
  37.            seq = []
  38.            joined_seq=""
  39.            seq_string=""
  40.            count=count+1
  41.     #time.sleep(1)
  42.     led.value = False
  43.     #time.sleep(1)

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at