Today our 6th graders started coding inside the Arduino IDE (integrated development environment). We looked at the minimum code needed to blink a light on and off at a given frequency. Timing defaults to milliseconds, so if we want to blink a light once per second then we instruct the Arduino with code that functions like this:
1) Turn on the light
2) Wait 1000 milliseconds
3) Turn off the light
4) Wait 1000 milliseconds
5) Go back to step #1 and start over
Step #4 is non-intuitive and it takes a while for students to see that without that 2nd delay the light would appear to stay on and not blink because the microcontroller would turn off the light after the initial delay and then jump back to step number one so quickly the human eye could not see the light blink off.
Some questions to ask at home: "How many milliseconds are there in a 1/4 of a second?" or "What values for the delay do we need to blink the light on for 3.25 seconds and off for 9 seconds?"
Soon students will start to learn to use variables in code so each time we make a loop though the instruction set we can increment that variable.