Lab 2 – Arduino Programming Basics

Arduino Code

void myCode(){

celerate(1,0,15,2.5); This tells the first motor to accelerate from 0 to 15 and 2.5 seconds.

motorSpeed(1,15); This sets the speed of motor 1 to 15.

goFor(1); This tells the command to run for 1 second.

brake(1); This stops the first motor.

celerate(2,0,27,4); This accelerates motor 2 from 0 to 27 in 4 seconds.

motorSpeed(2,27); This sets the speed of motor 2 to 27.

goFor(2.7); This tells the command to run for 2.7 seconds.

celerate(2,27,15,1); This tells motor 2 to decelerate from 27 to 15 in 1 second.

brake(2); This stops motor 2.

reverse(2); This tells motor 2 to reverse direction.

celerate(4,0,31,2); This accelerates motor 4 from 0 to 31 in 2 seconds.

motorSpeed(4,35); This sets the speed of motor 4 to 35.

goFor(1); This tells the command to run for 1 second.

brake(2); This stops motor 2.

goFor(3); This tells the command to run for 3 seconds.

brake(4); This stops motor 4.

goFor(1); This tells the command to run for 1 second.

reverse(1); This tells motor 1 to reverse direction.

celerate(1,0,19,2);This tells the first motor to accelerate from 0 to 19 and 2 seconds

motorSpeed(2,35); This sets the speed of motor 2 to 35.

motorSpeed(1,19); This sets the speed of motor 1 to 19.

goFor(2); This tells the command to run for 2 seconds.

motorSpeed(2,19); This sets the speed of motor 2 to 19.

goFor(2); This tells the command to run for 2 seconds.

celerate(4,3,2,3); This decelerates all motors from 3 to 2 in 3 seconds.

brake(4); This stops all motors.

}

Lab 2 Report