Turn On The Built-In LED on Arduino Uno
Practice 1 To Turn On Arduino LED – In the previous article we already know the Arduino board and its variant. Now, let’s practice for the first time how to program arduino.
There are only 3 tools and materials:
- Arduino Uno
- Data Cable
- Arduino IDE Software
In this exercise, we will try to turn on the LED lights that are owned by Arduino Uno.
This LED is called the Arduino Builtin Led because this LED already exists (included) on the Arduino board and this led is connected to pin 13 digital I/O.
Basic Program is Blink
By default, the Arduino IDE has provided examples of programs that we can learn from in the File > Examples menu.
In this article, we will use the blink program example in the File > Examples > Basics > Blink.
int LED = 13;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
delay(1000);
}
The program is as follows and please copy and paste it into your Arduino IDE.
Before we upload the program to the Arduino Board, we first set the board and port that we want to use.
- Click the Tools menu
- Click Board > then select Arduino Uno
- Click Port > Select the port connected to Arduino Uno
Now please upload the program by clicking the Upload button.
If the notification is Done Uploading, it means that the Arduino IDE has successfully entered the blink program code into the Arduino Board.
You can see there is a led that turns on and off within a second.
Please Modify the Program
Now, try changing the value of 1000 on one of the delay(1000) lines with a value of 500 like the following program:
int LED = 13;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(1000);
}
Now, upload the popgram again by clicking the upload button. You will see the LEDs turn on and off faster.
That is the basic program how we can control the I/O pins of a microcontroller to turn on an LED.
This practice is a basic program and explanation that can later be applied to higher applications such as turning on lights.
May be useful.