Saturday, August 5, 2017

Basic Blink

A very simple circuit using very simple code. Pin (13) is an output for the LED. This output pin only has two output states:
  • ON or HIGH (+5V)
  • OFF or LOW (0V).

The program:
  • Turns the LED on - delays 1 second (1000 milliseconds)
  • Turns the LED off - delays 1 second (1000 milliseconds)
  • repeats this behavior over and over again.

Hookup for Basic Blink


--------------------------- Copy Code Below

void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000); //1 second (1000 ms per second)
digitalWrite(13, LOW);
delay(1000);
}

--------------------------- Copy Code Above

Going Further:

1) Replace literal value (13 here) 
with a variable for delay
2) Set the blink rate using a potentiometer
3) Use variable frequency Blink with a high power LED to create a Stroboscope

No comments:

Post a Comment