Shortened autonomous code with for loops and finished the needed code for the sensor.