Introduction: How to Blink a Led
Hello to everyone. Let's introduce myself. My name is Dimitris and i am from Greece.I love very much Arduino becasuse it's a smart board.I will try to describe as best as i can this instructable in order to make by anyone. So let's start.
Step 1: Materials
I used these materials:
- Arduino Uno
- Resistor 100 Ohm
- Jumper wires male to male
Step 2: The Circuit
First, place the led on the breadboard. On the positive “leg” of the led, place the resistor and on the other side of the resistor connect a cable which leads to pin 7 of the Arduino. On the negative “leg” of the led, connect a cable that leads to the Arduino GND.
The led has two “legs”, the long “leg” is the positive and the other “leg” is the negative. Be careful with your connection or else you will burn it. Carefully connect the positive “leg” of the LED to the resistor and run a cable from the ground “leg” to the GND pin of the Arduino. The circuit will be exactly as the diagram shown.
Step 3: The Code
The code is very simply to understand. Every sketch of arduino consists of two methods. These methods are void setup and void loop.
The void setup method executes only once when Arduino powered by batteries or other source. This method is used for initialization.
The void loop method executes the commands that you have written again and again until Arduino board disconnected from battery or other source. Below we examine the sketch line by line:
int led = 7;
- int led = 7;
This means that our led is connected to pin 7 on arduino board. This symbol “;” means that we finish the statement.
- void setup()
As we mentioned before the void setup() method is executed only once. We set our led as OUTPUT. In this way the Arduino understands that our led is connected to pin 7.
- void loop()
As we mentioned before the void loop() method is executed again and again. The digitalWrite method is a method provided by arduino interface.It takes two arguments(the first is our led and the second is the word HIGH or LOW).
HIGH means the led is on
LOW means the led is off
The delay() method is set to 1000 (1 second).It is very important the delay method because without it the led will be on all the time.
Have fun :)