add_library('serial') port = "COM5" def setup(): size(512, 512) #setup the serial port print Serial.list() LF = 10 print "Connecting to ", port myPort = Serial(this, port, 115200) myPort.bufferUntil(LF) x, y = -1, -1 def draw(): global x, y if x >= 0 and y >= 0: point(x, y) def serialEvent(evt): xy = evt.readString().strip().split() if len(xy) == 2: global x, y x, y = int(xy[0])/2, int(xy[1])/2