0% found this document useful (0 votes)
60 views

An Example - Introduction To The Arduino Uno Board (Blinking LED)

This document provides instructions for connecting an LED to an Arduino Uno board and programming it to blink using the Arduino IDE. It describes compiling and uploading a sketch that uses digitalWrite() and delay() functions to turn the LED on and off. The LED and resistor are connected to pin 13, which is configured as an output. When uploaded, the sketch causes the LED to blink on for 1 second and off for 1 second repeatedly.

Uploaded by

Rexie Curioso
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

An Example - Introduction To The Arduino Uno Board (Blinking LED)

This document provides instructions for connecting an LED to an Arduino Uno board and programming it to blink using the Arduino IDE. It describes compiling and uploading a sketch that uses digitalWrite() and delay() functions to turn the LED on and off. The LED and resistor are connected to pin 13, which is configured as an output. When uploaded, the sketch causes the LED to blink on for 1 second and off for 1 second repeatedly.

Uploaded by

Rexie Curioso
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

An example – Introduction to the Arduino Uno

board (Blinking LED)

A. Objectives
This example aims to familiarize the student with the basic operation of the Arduino
Uno board, and Integrated Development Environment (IDE). By the end of the exercise,
the student should be able to know the basic functionalities of the IDE.

B. Questions
• How do you compile and upload a sketch file into the Arduino Board using
the IDE?
• How can the configuration of the pins be specified in the programming?
• What functions are always required in a sketch?
C. Materials Needed
• 1 x Arduino Uno board and USB cable
• 1 x 5mm/3mm Red LED
• 1 x 470Ω resistor
• 1 x breadboard
D. Using the Arduino IDE
1. Proceed to the Arduino Folder and double-click the arduino application to
open the Arduino IDE which is also shown below:

Figure 13: Screenshot of the Arduino IDE. The workspace is very simple and frequently used
buttons are easy to access
2. Type the following lines of code on the front panel. The code can also be
found in the examples folder of Arduino. To copy it, just navigate from arduino-
00XX > examples > Basics > Blink. See Appendix under Structure, Functions
and Time or Section F for the functions' definitions
1 void setup(){
2 pinMode(13,OUTPUT);
}
3 void loop(){
4 digitalWrite(13,HIGH);
5 delay(1000);
6 digitalWrite(13,LOW);
7 delay(1000);
}

3. Press Ctrl + S or Icon on the IDE to save your sketch (the term for a
source code in Arduino).

4. Click the Verify Button (A on fig. 14) to check if the sketch has no errors. At
the bottom of the screen you should see if the sketch was successfully scanned
free of problems (B on fig. 14). Moreover, the size of the sketch file (C on fig. 14)
is also indicated on the black screen at the bottom to shows that it fits the flash
memory of the Arduino Uno.

Figure 14: Screenshot of the Blink code after compilation. The verify button looks just like a play
button and is located at the upper left corner. Successful compiling will be indicated at the bottom.
If an error or problem occurred, it will be shown in the black screen.
E. Test your Program
1. Connect an LED to a 470Ω resistor. Note: that the longer leg of the LED is
the positive (connected to one end of resistor and the shorter one is the negative
(connected to the ground). The other end of the resistor should then be connected
to the specified pin which is 13.

Figure 15: Schematic diagram of blink circuit.

2. Check if the board selected in the IDE is the one you are using, the Arduino
Uno board.

Figure 16: Screenshot showing Arduino Uno as selected board. If you have a different type of
Arduino board, just select it from this list.
3. Next, make sure that the Arduino board’s COM port is properly identified by
the IDE. To do this, connect the board to the computer then from the IDE front
panel go to Tools > Serial Port (A on fig. 17). A list of COM’s should be there,
choose the COM number associated with the microcontroller board. Note: the
microcontroller board’s COM no. is found near the name of the device’s driver in
Device Manager (B on fig. 17) [2].

Figure 17: Screenshot of both the Device Manager and Arduino IDE windows. Note that the COM
number selected as Serial Port must be the same one found beside the device’s name

4. Finally, upload the sketch made earlier into the board by clicking the icon
in the IDE. The status of the upload can be found near the bottom of the program
[2].

Figure 18: Screenshot showing a successful upload. Sometimes an error occurs because the COM
port of the Arduino UNO was not properly specified. To solve this just follow Step 2.
5. If the Arduino Uno is connected to the PC or power source the LED should
light up for 1 second and turn off for 1 second repeatedly.
Figure 19: Photo of the LED blinking. Note that the small LED on the board is also blinking because
it is also connected to pin 13.

F. Code explanations:
Line Explanations
No.
1 Creates a function called setup. The function type is void and
therefore does not return any value after execution. This is only
read once in a file execution and is required in a sketch.
2 The function pinMode() configures the specified pin which is 13
in this sample. It sets digital pin 13 as output.
3 Creates a function called loop. The function type is also void and
therefore also does not return any value after execution. This is
read repeatedly in a file execution and usually where the main
program is. This is also required in a sketch.
4 The digitalWrite() function writes a high(5V) or low(0V) on a
specified pin. In this case, a high state is written on pin 13 to light
the LED.
5 The delay function needs a constant or variable of how long in
millisecond the delay will be. This line prolongs for 1000
millisecond the LED at ON state.
6 Similar to line 4, pin 13 was set this time to low to turn off the
LED.
7 This line is the same as line 5 and prolongs the LED at OFF
state for 1 second.
G. What to expect
You have just written a sketch and programmed the Arduino Uno board to cause
both the external LED and built-in LED connected to pin 13 to blink. You should see the
LED blink when the board is connected to the PC by a USB cable or the board is
connected to a DC supply.
H. Summary
In this exercise, you have learned how to create .pde files or sketches using the
Arduino IDE. You have also learned how to access and control – specifically, turn ON
and OFF –an LED connected to pin 13 of the Arduino Uno Board.

You might also like