Experiment No 1
Experiment No 1
1
Introduction to Arduino Uno and its programming
Introduction
This lab describes the Arduino basic theory and software description that are commonly
used in embedded system. In this lab, we have to learn the basic steps in the software
which is used for programming in Arduino.
LAB Objectives
Understand the basic theory of microcontroller (Arduino)
Understand the basic hardware description of Arduino
Understand the software which is used for programming in Arduino
LAB Outcomes
By the end of this experiment, student will have basic understanding the Arduino
features and its programming.
Theory Overview
Arduino Hardware
The Arduino board is where your code is executed. The board can only control and
respond to electricity, so specific components are attached to it to enable it to
interact with the real world. These components can be sensors, which can be
convert some aspect of the physical world to electricity so that the board can sense
it or actuators, which get electricity from the board convert it in to something that
changes the world.
Figure 4.1 Arduino Board Description
We need to be familiar with the Arduino pins, so these pins are discussed as follows
Each of the 14 digital pins on the Uno can be used as an input or output using pinMode(),
digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can
provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected
by default) of 20-50 K ohms. In addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
These pins are connected to the corresponding pins of the ATmega8U2 USB-to- TTL
Serial chip.
External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a
low value, a rising or falling edge, or a change in value.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite ()
function.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI
communication using the SPI library.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.
The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground to 5 volts,
though is it possible to change the upper end of their range using the AREF pin and the
analogReference() function. Additionally, some pins have specialized functionality:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used
to add a reset button to shields which block the one on the board.
Arduino Software
Software programs called sketches are created on a computer using Arduino integrated
development environment IDE. The IDE enables to edit or write a code and convert this
code in to instructions that Arduino hardware understands. The open-source Arduino
environment makes it easy to write code and upload it to the i/o board. This link you can
download the software needed from: http://Arduino.cc/en/Main/Software The software
doesn’t need to be setup jest run the program normally.
Step 1- First start Arduino program then the following figure should appear as
shown in figure 4.2
\
\\\\\
Step 2- Click tools and check the board Arduino Uno is chosen (“This option
can be changed according to the Arduino’s type needed to be programmed”)
shown in figure 4.3
Step 5- New window will open as follows click upload button then the software will
compile the program for errors and then upload it to the Arduino as shown in figure 4.6
Upload button
Equipment / Apparatus
Arduino Kit
DC Power Supply 5 Volt
Digital Multimeter
Breadboard
Resistors 10 Ω to 1kΩ
LED’s
Wires
Schematic Diagram
int LED=13;
void setup ( )
{
pinMode(LED, OUTPUT);
}
void loop ( )
{
digitalWrite (LED, HIGH);
delay(500);
digitalWrite (LED, LOW);
delay(500);
}
After program the code inside Arduino check the status of LED on your
breadboard and fill the table 1.2
Resistor Value:
Time Delay :
Precautions
Before you start to mess with a computer there are basic guidelines to be aware of,
such as turn the power off and watch out for static electricity. The three kind of
activity that requires touching the Arduino
Question 1
Write a C code in Arduino for blinking an LED on pin number 8 in Arduino with some
specified delay. Also sketch the circuit diagram and paste the hardware resultalso
Question 2
Write a C code in Arduino for blinking an LED on pin number 8 ,7 in Arduino with some
specified delay. Also sketch the circuit diagram and paste the hardware result also.
Question 3
Write a C code in Arduino to perform a simple sequential program to turn ON and Turn
OFF 6 LEDS sequentially. Also sketch the circuit diagram and paste the hardware result
also.
LAB Assessment
Date Signature