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).

Controlling Alternated Current – Relays

Alternated current and direct current live in very different realms, think lighting and appliances vs electronics and computers. You will never have AC flowing on your breadboard. However, with our 5V arduino circuits we can turn on and off bigger things using relays. Relays are physical switches that can be controlled by a low voltage electric signal. We are using relays in two relatively safe setups:

powerswitchtail2_LRG

The Power Switch Tail is a self contained plug-and-play extension chord controlled by a digital signal (+5V). You plug the +in to the arduino digital output, the -in to ground (you can leave the gnd pin disconnected) and control the extension chord as you would control an LED, by sending a digitalWrite(pin, HIGH) to the appropriate output. In order for the Relay to click the Power Switch Tail has to be plugged in an outlet. Always disconnect the AC stuff when you are working on the circuit.

IMG_7307

Posted in

Post a comment