01 - Laboratory - Exercise - 1 (Full Permission)
01 - Laboratory - Exercise - 1 (Full Permission)
Laboratory Exercise 1
Arduino Uno 328 Board and IDE
Familiarization
OBJECTIVES:
Identify the characteristics of Arduino Integrated Development
Environment (IDE) that will be used in programming the microcontroller
ATMega328,
and explore Arduino 328 board and IDE interface.
MATERIALS:
PROCEDURES:
Note: Please observe safety precautions and proper handling while conducting the
laboratory experiment. This experiment is to be performed under faculty supervision.
2. Once the download is complete, install the program by simply following the
instructions. Once installed, run the program and a window will pop out.
a. Verify -
b. Upload -
c. New -
d. Open -
e. Save –
f. Serial Monitor -
4. Let us now familiarize ourselves with the Menu bar of the development environment. Discuss the
following words below.
Edit
Copy for Forum -
Copy as HTML -
Menu bar
Toolbar
Sketchbook
Compiling window
Sketch -
Verify/Compile -
Add File... –
Import Library -
Tools -
Auto Format -
Archive Sketch –
Board –
Serial Port –
Programmer –
Burn Bootloader -
Sketchbook -
Uploading-
Serial Monitor-
4. Let us open an example to check whether we can connect to the board. Click File > Examples >
Basics > Blink. Another screen should pop out and look like what is shown below.
8. In the sketchbook, change the argument of the delay() function from 1000 to 5000. This will make the
red LED blink every five seconds. Your new code should look like what is shown below.
9. Verify the program by clicking . Upon a successful compilation, you should be able to see the
screenshot below.
10. We are now ready to upload our code to the ACEduino board. Click . After a successful upload,
the compiling window should look like what is shown below.
11. Notice that the blinking or the light is approximately equal to five seconds.
1. Let us now familiarize ourselves with the ACEduino w/ ATmega328 board. Shown in Figure 1.3 is the
ACEduino w/ ATmega328 board. This ATmega 328 has the following peripherals and features:
Different communication lines available - UART (Rx, Tx), I2C (SDA, SCL) and ISP (MISO, MOSI,
SCL)
32KB Flash Memory and automatic power selector between USB and DC power
a. DC jack –Supply a Power DC jack when the Arduino is ready to be deployed. A 9-V converter
should be good enough to make this board run and at the same time provide power to other
external peripherals to be attached to the Arduino board.
c. Analog inputs –These are analog inputs that will be converted to its digital equivalent so that the
microcontroller can process them.
d. ATmega328 microcontroller chip – This is the brain of the Arduino board that does the processing
of all inputs and outputs from and to the microcontroller.
e. Digital I/O ports –These are general input/output ports that can be use to read and write to the
external peripherals attached to the Arduino board. Note that I/O ports 9 –11 can be used as PWM
ports.
f. Digital I/O ports –These are general input/output ports that can be use to read and write to the
external peripherals attached to the Arduino board. Note that I/O ports 3, 5 –6 can be used as
PWM ports.
g. A to B printer/Scanner cable –This is not provided once you bought the Arduino kit. This cable is
used to connect the Arduino board to the IDE in the computer for debugging and uploading of
program codes.
e f
a
b c
Figure 1.3 Arduino w/ ATmega328 board
5. Note that a new window will appear just like what is shown below. A new sketch has a default file
naming system of sketch_date. What are the codes that can you see? Write it down on the space
provided.
a. The setup() function is called when a sketch starts. Use it to initialize variables, pin modes,
start using libraries, etc. The setup function will only run once, after each powerup or reset
of the Arduino board.
b. After creating a setup() function, which initializes and sets the initial values, the loop()
function does precisely what its name suggests, and loops consecutively, allowing your
program to change and respond. Use it to actively control the Arduino board.
7. Let us now analyze the code we used in simply trying to make the LED in the Arduino board blink. The
code for LED blinking is re-shown below. Let us understand each line of the program code.
a. pinMode - Configures the specified pin to behave either as an input or an output. The
syntax of the said built-in function is:
Parameters: pin: the number of the pin whose mode you wish to set mode:
either INPUT or OUTPUT
b. digitalWrite –Write a HIGH or a LOW value to a digital pin. If the pin has been configured
as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or
3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. If the pin is configured as an
INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup. Writing
LOW will disable the pullup. The pullup resistor is enough to light an LED dimly, so if LEDs
appear to work, but very dimly, this is a likely cause. The remedy is to set the pin to an
output with the pinMode() function. NOTE: Digital pin 13 is harder to use as a digital input
than the other digital pins because it has an LED and resistor attached to it that's soldered
to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at
around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull
the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital
input, use an external pull down resistor. The syntax of this built-in function is:
c. delay() - Pauses the program for the amount of time (in milliseconds) specified as
parameter. (There are 1000 milliseconds in a second.)
References: