Dim with Blink
Step 1 - Build the Project
This program illustrates just how fast code can move. After you assign pin 13 to be an output in the setup, you combine the digitalWrite and the ‘for’ loop structure to create a bright-dim-bright blink cycle.
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
The ‘for’ loop is specifying “If the variable i is less than 50, do this loop again and add 1 to i”. After 50 times through the loop i will not be less than 50, so the for loop breaks. Inside that loop is a bit of code to blink an LED by writing it HIGH, waiting 1 millisecond (1/1000th of a second), and then writing it LOW.
You’re blinking it so fast (50 times a second!) that the LED looks dim to your eye. Don’t believe it? Just increase the delays in the ‘for’ loop by a bit. You’ll start to notice the light flicker until it’s obviously turning on and off. This is related to the concept of persistence of vision.