day 22
Python code import serial #Import Serial Library from visual import * #Import all the vPython library arduinoSerialData = serial.Serial('COM3', 9600) #Create an object for the Serial port. Adjust 'com11' to whatever port your arduino is sending to. measuringRod = cylinder( axis=(0,0,10),radius= .5, length=6, color=color.yellow, pos=(-3,0,0)) lengthLabel = label(pos=(0,0,5), text='Target Distance is: ', box=false, height=10) orientation = 0 x = 0 y = 1 z = 2 while (1==1): #Create a loop that continues to read and display the data rate(20)#Tell vpython to run this loop 20 times a second if (arduinoSerialData.inWaiting()>0): #Check to see if a data point is available on the serial port myData = arduinoSerialData.readline() #Read the distance measure as a string myData = myData.strip() mylist = myData.split(',') ax = mylist[x] ay = mylist[y] az = mylist[z] #print ax,ay,az #Print...