import serial import time # configure the serial connections ser = serial.Serial() ser.baudrate = 115200 ser.port = 'COM8' ser.open() # print(ser.name) # check which port was really used print(ser.is_open) # while True: x = b'\x90\xeb\x03\x02\x06\x00\x10\x32\x54\x76\xff\x02' #setup three registers ser.write(x) time.sleep(0.5) x = b'\x90\xeb\x01\x02\x08\x00\xff\x12' #enable two digits ser.write(x) time.sleep(0.5) x = b'\x90\xeb\x01\x02\x08\x00\xff\x22' #enable three digits ser.write(x) time.sleep(0.5) x = b'\x90\xeb\x01\x02\x08\x00\xff\x32' #enable four digits ser.write(x) time.sleep(0.5) # x = b'\x90\xeb\x01\x02\x08\x00\x00\x32' #clear decimal points ser.write(x) # for y in range(16): z = (y + (y<<4)).to_bytes(1,byteorder='big') x = b'\x90\xeb\x01\x02\x06\x00' x = x + z + z ser.write(x) time.sleep(0.5) # ser.close()