Arduino :
Introduction & Programming
SVIT, Vasad
What is Microcontroller?
What is an Arduino ?
A microcontroller board contains on-board power supply,
USB port to communicate with PC, and an Atmel
microcontroller chip.
Open Source electronic prototyping platform based on
flexible easy to use hardware and software.
An open source hardware for anyone interested in creating
interactive objects or environment.
Arduino Capabilities…
Arduino Flavours
Arduino Features
Arduino Board Details
Arduino UNO 14 Digital I/O pins (6 pins PWM)
6 Analog I/O pins
2 Tx-Rx pins
Arduino Mega Larger Than UNO
54 Digital I/O pins (15 pins PWM)
16 Analog I/O pins
Arduino Due 54 Digital I/O pins
16 Analog I/O pins
5 Tx-Rx pins
Arduino Nano Smaller than UNO
13 Digital I/O pins
8 Analog I/O pins
Arduino LilyPAD Circular Shape
54 Digital I/O pins
16 Analog I/O pins
Arduino YUN Inbuilt WiFi
14 Digital I/O pins
12 Analog I/O pins
Arduino Features
Pin Description
Pin Category Pin Name Details
Power Vin, 3.3V, 5V, GND Vin: Input voltage to Arduino when using an external
power source.
5V: Regulated power supply used to power
microcontroller and other components on the board.
3.3V: 3.3V supply generated by on-board voltage
regulator. Maximum current draw is 50mA.
GND: ground pins.
Reset Reset Resets the microcontroller.
Analog Pins A0 – A5 Used to provide analog input in the range of 0-5V
Input/Output Pins Digital Pins 0 - 13 Can be used as input or output pins.
Serial 0(Rx), 1(Tx) Used to receive and transmit TTL serial data.
External 2, 3 To trigger an interrupt.
Interrupts
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.
SPI 10 (SS), 11 (MOSI), Used for SPI communication.
12 (MISO) and 13
(SCK)
Inbuilt LED 13 To turn on the inbuilt LED.
TWI A4 (SDA), A5 (SCA) Used for TWI communication.
Arduino Uno Technical Specifications
Microcontroller ATmega328P – 8 bit AVR family microcontroller
Operating Voltage 5V
Recommended Input 7-12V
Voltage
Input Voltage Limits 6-20V
Analog Input Pins 6 (A0 – A5)
Digital I/O Pins 14 (Out of which 6 provide PWM output)
DC Current on I/O Pins 40 mA
DC Current on 3.3V Pin 50 mA
Flash Memory 32 KB (0.5 KB is used for Bootloader)
SRAM 2 KB
EEPROM 1 KB
Frequency (Clock Speed) 16 MHz
What do we need?
Arduino’s processor
basically uses the Harvard
architecture where the
program code and program
data have separate
memory.
It consists of two
memories- Program
memory and the data
memory.
The code is stored in the
flash program memory,
whereas the data is stored
in the data memory.
The Atmega328 has 32 KB
of flash memory for storing
code (of which 0.5 KB is
used for the bootloader), 2
KB of SRAM and 1 KB of
EEPROM and operates with
a clock speed of 16MHz.
What do we need?
Getting started with Programming
Bare minimum code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run
repeatedly:
}
Bare minimum code
setup : It is called only when the Arduino is
powered on or reset. It is used to initialize
variables and pin modes
loop : The loop functions runs continuously
till the device is powered off. The main logic
of the code goes here. Similar to while (1) for
micro-controller programming.
PinMode
A pin on arduino can be set as input or
output by using pinMode function.
pinMode(13, OUTPUT); // sets pin 13 as
output pin
pinMode(13, INPUT); // sets pin 13 as input
pin
Reading/writing digital values
digitalWrite(13, LOW); // Makes the output voltage on pin 13 ,
0V
digitalWrite(13, HIGH); // Makes the output voltage on pin 13 ,
5V
int buttonState = digitalRead(2); // reads the value of pin 2 in
buttonState
analogRead(A0); // used to read the analog value from the pin
A0. Range is 0 to 1023
analogWrite(2,128); //Write an analog value to a pin value of 0
to 255
Thank You…