Table of Contents
To light up an led we just need a DC power source and ground terminal here we connect led anode terminal (+) to pin number 13 (digital IO) so that if we program our code as pin number 13 as HIGH (+5V), it behaves as power source and Cathode terminal (–) of led to the ground terminal of Arduino so that the circuit will get complete.
After uploading the program to Arduino, if we give power to Arduino Uno then it will light up the LED.
Required hardware or components for Lighting up LED using Arduino
S.N. | Component | Quantity |
---|---|---|
1. | Arduino Uno | 1 |
2. | Breadboard | 1 |
3. | LED | 1 |
4. | Resistor 220 or 280 ohm | 1 |
CIRCUIT DIAGRAM
S.N. | Arduino | LED |
---|---|---|
1. | 13 | Anode (+) |
2. | GND | Cathode (-) |
ARDUINO CODE: LIGHT UP LED USING ARDUINO UNO
void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); }
CODE EXPLANATION
Step-1: In the setup function we decide the mode of digital pins either as INPUT or OUTPUT. Let’s concentrates on output for now.
Function “pinMode( )” is used to define the pin working mode as an input/output.
In this function we have to pass two argument –
- First one is pin number and
- Second is its mode, pinmode(pinNumber, mode).
In this we set pin number 13 as output: pinmode(13, OUTPUT).
void setup() { pinMode(13, OUTPUT); }
Step-2: In the loop function we are using one inbuilt function that is digitalWrite( ).
Function “digitalWrite( )” is used to instruct the controller/Arduino to set the state of a particular digital pin as either LOW or HIGH.
In digitalWrite( ) function we also pass two argument –
- First one is pin number and
- Second is its state, digitalWrite(pinNumber, state).
In this we set pin number 13 output as HIGH: digitalWrite(13, HIGH).
void loop() { digitalWrite(13, HIGH); }
And the loop gets executed continuously and the LED remains HIGH all the time.
READ NEXT
LED BLINKING USING ARDUINO UNO
95187 309356This really is a excellent common sense write-up. Quite beneficial to 1 who is just finding the resouces about this part. It will surely support educate me. 563578
177278 891544Theres noticeably a bundle to find out about this. I assume you made certain great points in features also. 406944
759662 107690We are a group of volunteers and opening a new system in our community. Your web web site given us with valuable information to function on. Youve done an impressive job and our entire community will be grateful to you. 456650
516080 486164An intriguing discussion is worth comment. Im certain which you basically write regarding this subject, might possibly not be considered a taboo topic but typically persons are too small to communicate on such topics. To an additional. Cheers 403630
951588 827556Your blog is one of the much better blogs Ive came across in months. Thank you for your posts and all the greatest with your function and blog. Seeking forward to reading new entries! 679252
730262 219779Spot up for this write-up, I seriously believe this web site needs a lot a lot more consideration. Ill apt to be once much more to learn additional, appreciate your that information. 601455
825107 553927Wanted posting. Loads of exceptional writing here. I wish I saw it located the website sooner. Congrats! 388663
475769 714251Hey there. I want to to inquire somethingis this a wordpress weblog as we are thinking about shifting more than to WP. Also did you make this theme on your personal? Thanks. 650644
326675 315259Hi, you used to write exceptional articles, but the last several posts have been kinda boring I miss your super writing. Past several posts are just a little out of track! 35282
196321 346714conclusion which you are completely proper but a few require to be 790543