UART.py 258 B

12345678910111213141516
  1. import PikaStdLib
  2. import machine
  3. time = machine.Time()
  4. uart = machine.UART()
  5. uart.init()
  6. uart.setId(1)
  7. uart.setBaudRate(115200)
  8. uart.enable()
  9. while True:
  10. time.sleep_ms(500)
  11. readBuff = uart.read(2)
  12. print('read 2 char:')
  13. print(readBuff)