Department of Electrical Engineering C.I.I.
T ATD
The Arduino Platform
Resorce Person: Engr. Usman Khalid
Lecturer EE Dept.
COMSATS ATD
1
Arduino Environment
• Development Board
• Arduino IDE
• Arduino Shields
2
Arduino Environment
A Development Board
8-bit Microcontroller
Programming hardware
USB programming interface
I-0 pins
3
Arduino IDE
Arduino Integrated
development environment.
Cross-compiler
Debugger
Simulator
programmer
4
Arduino Shields
• Special-purpose “shields”
Boards
unique functionalities
easy to attach
good libraries provided
5
6
Development Board
7
8
Microcontrollers
ATmega328 is microcontroller
programmed by the user
Application code
User code
ATmega16U2 handles USB
communication
Firmware
USB interface, power mode,
reset etc.
A .hex file is generated from the
.elf file after linking
9
10
11
12
13
Arduino Sketch
A program is called a Sketch
C++ program using Arduino library fuctions
C++ is a superset of C
All C programs are legal C++
C++ also include classes
Group together data and functions that are
related
14
Sketch Structure
Setup() function
A sketch does not have a main() function
Every Sketch has a setup() function
Executed once when Arduino is powered up
Used for initialization operations
Returns no value, take no arguments
void setup()
{
……
} 15
Loop() function
Every Sketch has a loop() function
Executed iteratively as long as the Arduino is powered up
loop() starts executing after setup() has finished
loop() is the main program control flow
Returns no value, take no arguments
void loop()
{
……
}
16
17
18
19
Buttons for common commands
20
Verify
Upload
21
22
23
Blink LED Sketch
24
Turn ON and OFF LED connected to pin 13,
when button is turned ON and OFF connected
to pin 2 of the Ardunio.
25
26
27
Interfacing LCD to Arduino
28
29
30
Bibliography
• https://www.arduino.cc/
• https://electrosome.com/interfacing-lcd-arduino-uno/
• http://www.ics.uci.edu/~harris/publications.html
• http://www.homautomation.org/2014/03/06/running-
atmega328-in-a-standalone-mode-without-arduino-
shield/
31