Tab Content
Tab Title
Instructions
Tab Content
  1. Type: “delay(2000);” after “myservo.write(180);” and before the last curly bracket.

STEM Connections

This delay function will cause the program to pause and not read the next line for 2000 milliseconds (or 2 seconds). Meanwhile, the Servo has been instructed to move to 180 degrees, which it will do and then remain there until it receives another command.

Remember, the loop function runs any lines of code that are between the curly brackets that follow it over and over again. So, the program will not end after it moves the Servo to 180 degrees and pauses for 2000 milliseconds. Because this line of code is part of the loop function, the program will return to the first line of code in the loop, which instructs the standard Servo to move to 0 degrees. 

Tab Title
Troubleshooting
Tab Content

‘delay’ didn’t turn orange

  1. Check the spelling of the word “delay” and make sure that no letters are capitalized.
Tab Title
Implementation
Tab Content
  1. This is the final line that will complete the program. Again, we need this delay to give time for the Servo to physically get to its new position.
     
  2. Have your students double check that they have written all of the necessary code to control their Servo. A missed semicolon or a word spelled wrong will prohibit your code from uploading properly.
     
  3. If your students are using the Wearable Tech notebooks, they can use them to double check their work.
     
  4. Question for students: if you only had 1 state (or 1 command) for the standard Servo, what would that look like?
    Answer: it wouldn’t move because it i’s a position based Servo. If you program it to go to one position, then it will stay there.
Instruction Category