Complete the code to get the current time in milliseconds.
unsigned long currentTime = [1]();The millis() function returns the number of milliseconds since the Arduino started running.
Complete the code to check if 1000 milliseconds have passed since lastTime.
if (currentTime - lastTime [1] 1000) {
We check if the difference is greater than or equal to 1000 to see if 1 second passed.
Fix the error in the state machine update condition.
if (state == [1] && currentTime - lastTime >= interval) {
The state variable is usually an integer representing the current state, so we compare it to a number like 1.
Fill both blanks to update the state and reset the timer.
state = [1]; lastTime = [2];
We set the state to 2 and reset lastTime to the current time using millis().
Fill all three blanks to create a timing-based state machine that toggles an LED every second.
unsigned long [1] = 0; int [2] = 0; const unsigned long [3] = 1000;
lastToggle stores last time LED toggled, state tracks LED on/off, and interval is the delay time.
