I'm trying to send data from PC to STM32. Finally, the data will be displayed on the LCD.
Code on PC:
Code: Select all
import serial
import time
def main():
ser = serial.Serial('COM5', 115200)
time.sleep(2)
print(ser)
i = 0
while i<=5:
t = ser.write('test'.encode())
i += 1
if __name__ == "__main__":
main()
Code: Select all
# main.py
import machine
import pyb
uart = machine.UART(2, 115200)
uart.init(115200, bits=8, parity=None, stop=1, timeout=2000)
while True:
pyb.LED(4).on()
t = uart.read()
if t:
pyb.LED(1).on()
pyb.delay(200)
pyb.LED(1).off()
else:
pyb.LED(3).on()
pyb.delay(200)
pyb.LED(3).off()
pyb.delay(200)
pyb.LED(4).off()
pyb.delay(200)
Code: Select all
Traceback (most recent call last):
File "main.py", line 24, in <module>
KeyboardInterrupt:
MicroPython v1.12 on 2019-12-20; F4DISC with STM32F407
Type "help()" for more information.
>>> testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
>>>