UART.py 246 B

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