- Find this text in two lines of the Blink code: “delay(1000);”
- Change the text from “delay(1000);” to “delay(500);” in both lines of code.
STEM Connections
Delay is another function in the Blink code. Changing the number in the delay function changes the rate that the LED blinks. The number in the delay function is measured in milliseconds. There are 1,000 milliseconds in 1 second. Changing the number in the parenthesis from 1000 to 500 will change the delay from 1000 milliseconds (or 1 second) to 500 milliseconds (or half a second). Any positive whole number can be used in the delay function, and different numbers can be used in both the delay functions.
All the text in computer code must be written correctly into order for the code to work properly. Similarly, some words and some letters must be capitalized, and semicolons and commas must be used in the proper places. These rules for how the text must be written in computer code is known as syntax. Syntax varies from one computer programming language to another. It takes time to learn the syntax of a new programming language.
“error compiling”
- Try clicking ‘upload’ again
“problem uploading to board”
- Be sure the port is connected to the right COM#
- Unplug and re-plug the USB cable (possibly using a different USB port if another one is available).
- Disconnect all wires from the Arduino board, unplug and replug the USB cable, close all Arduino windows and open the Blink code again, then try uploading again.
“expected ‘ ) ‘ before ‘;’ token
- Notice it highlights the area the problem is in
- You’re missing a parenthesis somewhere, make sure every parenthesis has its match
- Try using Ctrl+Z to undo any changes that you made to the code and start over.
“expected ‘;’ before ‘delay’ “
- Notice it highlights the area the problem is in.
- You’re missing a ‘;’ after a line of code. Check each line has a ‘;’ after it.
- Try using Ctrl+Z to undo any changes that you made to the code and start over.
Before changing the code, ask the students what you would need to change to make the LED blink faster. The correct answer is to change the value in the delay. Ask them if they need to increase the number or decrease the number in the delay to make the LED blink faster. The correct answer is to decrease the delay. Remind the students to be careful when changing their delay. You can show them what happens when you try to upload code with a missing ‘;’ or a missing ‘)’ . You can show them first by changing the value and before you upload, ask them why the LED didn’t change it’s blinking rate. Hoping someone will answer that you forgot to upload.