keyestudio
Share your creative ideas with us here
By keyes | 09 March 2024 | 0 Comments

How to blink a LED with arduino?


1.Introduction
Blink is a simple and fun
Arduino project that achieves a blinking effect by controlling LEDs on an Arduino development board. This project is suitable for beginners and can help them become familiar with the basic operation and programming of Arduino.

In this project we will use an Arduino board and an LED. By writing a simple program, we can control the LED to flash at a specific frequency.



2.Components Required

img

img

img

img

img

img

Keyestudio Plus Mainboard*1

Red LED*1

220Ω Resistor*1

Breadboard*1

Jumper Wire*2

USB Cable*1



3.Component Knowledge

LED:
 


 

It is a kind of semiconductor called “light-emitting diode”, which is an electronic device made of semiconductor materials (silicon, selenium, germanium, etc.). It has an anode and a cathode. The short lead (cathode) is grounded. The long lead (anode) is connected to 5V.

red-led-pinout-schematic

Resistor
 

A resistor is an electronic component in a circuit that restricts or regulates the flow current flow. Its unit is(Ω). 1 mΩ= 1000 kΩ,1kΩ= 1000Ω.

image-20230417114904650

We can use resistors to protect sensitive components, such as LEDs. The strength of the resistance is marked on the body of the resistor with an electronic color code. Each color code represents a number, and you can refer to it in a resistance card.

In this project, we provide eight 5-band resistors with different resistance values. Take three 5-band resistors as an example.

220Ω resistor*10

10KΩ resistor*10

1KΩ resistor*10

The connection between current, voltage, and resistance can be expressed by the formula: I=U/R.In the figure below, if the voltage is 3V, the current through R1 is: I = U / R = 3 V / 10 KΩ= 0.0003A= 0.3mA.


Breadboard
 

A breadboard is used to build and test circuits quickly before finalizing any circuit design. The breadboard has many holes into which circuit components like integrated circuits and resistors can be inserted. A typical breadboard is as follows.

The bread board has strips of metal which run underneath the board and connect the holes on the top of the board. The metal strips are laid out as shown below. Note that the top and bottom rows of holes are connected horizontally while the remaining holes are connected vertically.

The first two rows (top) and the last two rows (bottom) of the breadboard are used for the positive (+) and negative (-) terminals of the power supply, respectively. The conductive layout of the breadboard is shown in the following diagram.

When we connect DIP (Dual In-line Packages) components, such as integrated circuits, microcontrollers, chips and so on, we can see that a groove in the middle isolates the middle part, so the top and bottom of the groove is not connected. DIP components can be connected as shown in the figure below.


4.Circuit Diagram and Wiring Diagram

As shown in the diagram, we use digital pin 10 and connect one LED to a 220 ohm resistor to avoid high current to damage the LED.

Circuit Diagram:

Wiring Diagram:

Note: How to connect an LED

How to identify the 220Ω five-band resistor


5.Code

/*
LED_Blinking 
http//www.keyestudio.com
*/
int ledPin = 10; // defines numeric pin 10.
void setup()
{
pinMode(ledPin, OUTPUT);// defines PIN with connected LED as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // turn on LED
delay(1000); // wait a second.
digitalWrite(ledPin, LOW); // turn off LED
delay(1000); // wait a second
}


6.Result

Upload the project code, wire up components according to the wiring diagram, and power on. The LED will blink.



7.Explanation

pinMode(ledPin,OUTPUT): Before using the Arduino’s pins, you need to tell the control board whether it is INPUT or OUTPUT. We use a built-in function “pinMode()” to do this.

digitalWrite(ledPin,HIGH) : When using a pin as an OUTPUT, it can be commanded as HIGH (output 5V) or LOW (output 0V).

Leave a Reply

Your email address will not be published.Required fields are marked. *
Name
E-mail
Content
Verification code