- Type “standardServo.write(0);” between the curly brackets ({ and }) of the void loop function.
- Press enter and then type “continuousServo.write(0);”
- Press enter and then type “delay(2000);”
- Press enter and then type “standardServo.write(180);”
- Press enter and then type “continuousServo.write(180);”
- Press enter and then type “delay(2000);”
STEM Connections
The first 2 lines of code - “standardServo.write(0);” and “continuousServo.write(0);” - control how the Servos move. The standard Servo will move to position 0 degrees and the continuous Servo will spin fast to the left. The next line - “delay (2000);” - causes the Arduino to pause for 2 seconds before reading the next line of code. The next two lines - “standardServo.write(180);” and “continuousServo.write(180);” - cause the standard Servo to move to position 180 degrees and the continuous Servo to spin fast to the right. Then another “delay (2000);” causes the Arduino to pause for 2 seconds before reading the next line of code.
The number of code students need to write is fairly extensive, so give them enough time and make sure that they get all 6 lines written. If they are really struggling, show them how to copy and paste after they write the first 3 lines.
Remember that code has to be perfect in order for it to properly upload to the Arduino and control the Servos. Double-check that all 6 lines of the loop are included and that each line has a semicolon at the end. It may also be advisable that colored words in the code match the colored words in the video. The color of these words may change with software upgrades, but they should always be colored.