Digital Output – Blinking LEDs

digital_output

Current limiting resistor: it’s quite important or you may burn your LED.
Technically the proper value should be calculated according to the current and LED color but practically any values from 300 Ω to 2KΩ should be Ok. In the scheme it’s a 330 Ω

This is the example code “blink”
Arduino IDE > File > Examples > Basics > Blink

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
 
// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}
 
// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

Exercises
1. Make it blink faster!
2. Create a circuit with 2 and then 3 LEDs and program the arduino to control it
3. Make them blink in a pattern

Knight-Rider

Use all of your red LEDs make a circuit that reproduce the Knight Rider (you’re way too young for this reference).

Posted in

Post a comment