Blinking Lights

Overview

In this lesson, you will review using the loop function to blink and LED. The following shows an example of how you can write code to create an infinite set of pulses on a single digital pin on your microcontroller. The diagram shows how each line of code corresponds to each part of the pulse.

Exercise:

  1. Add an LED to your board if there is not already one on there. Don’t forget to use a resistor! Write a program to blink the LED using code shown above. Use a delay that is LARGE enough that you can see the LED flash on and off.

    IMPORTANT NOTE: You should generally avoid using digital pins 0 and 1 as either inputs or outputs. Using these pins might interfere with the programming of your device.

  2. Reduce the delay in your code until you can no longer see that the LED is flashing, essentially, so it is flashing so quickly (on and off) that your eye can no longer perceive the individual pulses of the LED.

  3. Write the value of this delay value in your notebook. Make sure to use the correct units. This is the rate of your critical flicker-fusion frequency (CFFF), the fastest flash you can perceive. This is very different for different animals. Read an article about CFFF here. It is pretty cool.