#!/usr/bin/python3 import serial with serial.Serial('/dev/ttyACM0') as ser: while True: for i in range(30): # selected LED for j in range(30): # LED for k in range(3): # colour for l in range(2): ser.write(b'f' if (i==j and k==1) else b'0') ser.write(b'n') ser.write(b'l') ser.write(b'q')