LESSON: HOLD BUTTON TO TURN ON LED
Step 4 - Code WALKTHROUGH

Code Walkthrough Text

Because the pushbutton is setup as an INPUT_PULLUP, it will digitalRead LOW when it is pressed. To make the light illuminate when the button is pressed, you need to tie digitalRead LOW to digitalWrite HIGH in the ‘if’ statement.

The else statement says “If the ‘if’ statement isn’t true, do this section of code.” Because the button can only be pressed or unpressed, the else is very straightforward.

It looks like this code isn’t doing much when you use it, but remember that the loop is being run hundreds of times a minute, so the reaction to the button press will be very fast!