Position Array
Here is some code for storing motor positions into an array:
#!/usr/bin/python3 from time import sleep def main(): print('Save Motor Position') positions = [] # create blank array # set up EV3 ev3 = Device('this') motor = ev3.LargeMotor('outB') # reset motor position to be zero (to start) motor.reset() # collect three motor positions for i in range(3): positions.append(motor.position) print("Position " + str(i) + " = " + str(positions[i])) sleep(1) # print out the individual motor positions (mp) for mp in positions: print(mp) if __name__ == '__main__': main()
More information on arrays in Python: