How to Control LEDs With Arduino

by chanidu1214 in Circuits > Arduino

937 Views, 1 Favorites, 0 Comments

How to Control LEDs With Arduino

Screenshot_20200317_150733.jpg
So in this tutorial I am going to light some leds with arduino uno board.

Things You Need

IMG_20200308_195433.jpg
Arduino uno
USB 2.0 Cable type
Male to male jumper wires
LEDs
Breadboard

Led Explanation

Screenshot_20200308_201512_com.sonymobile.sketch.jpg
a light-emitting diode (a semiconductor diode which glows when a voltage is applied).
The long side of the led is positive or plus(+) whereas the short side is negative or minus(-).

Setting Things

Screenshot_20200309_173252.jpg
This is the setup of the project.
Connect the ground(GND) pin of the arduino board to the minus(-) side of the led.
Then connect the plus(+) side of the led to 0 pin of the arduino board(if 0 pin does not work use pin 2).
Connect the arduino board to your computer with USB 2.0 Cable.
(you don't need a resistor as shown in the photo).

The Code

sketch_mar09a _ Arduino 1.8.1 3_17_2020 3_54_02 PM.png
sketch_mar09a _ Arduino 1.8.1 3_17_2020 3_52_25 PM.png
Go to arduino IDE and name your project as led and save it.
Then write the following code.
If you use pin 2 for the (+) side of the led, then just change the number 0 of the code to 2.(pinMode 2 and digitalWrite 2).

Final Result

IMG_20200317_163018.jpg
Now the led will light up if you have used the first code.
If you use the second code the light will blink.