Professional Documents
Culture Documents
Serial Pins 0 (Rx) and 1 (TX): Rx and Tx pins are used to receive and transmit TTL
serial data. They are connected with the corresponding ATmega328P USB to TTL serial
chip.
External Interrupt Pins 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 Pins 3, 5, 6, 9 and 11: These pins provide an 8-bit PWM output by using
analogWrite() function.
SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK): These pins are used for SPI
communication.
In-built LED Pin 13: This pin is connected with an built-in LED, when pin 13 is HIGH
– LED is on and when pin 13 is LOW, it’s off.
Along with 14 Digital pins, there are 6 analog input pins, each of which provides 10 bits
of resolution, i.e. 1024 different values. They measure from 0 to 5 volts but this limit can be
increased by using AREF pin with analog Reference () function.
Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire
library.
Fig.3.10: Arduino Board
A4 (SDA),
TWI Used for TWI communication.
A5 (SCA)
Arduino can be used to communicate with a computer, another arduino board or other
microcontrollers. The ATmega328P microcontroller provides UART TTL (5V) serial
communication which can be done using digital pin 0 (Rx) and digital pin 1 (TX). An
ATmega16U2 on the board channels this serial communication over USB and appears as a
virtual com port to software on the computer. The ATmega16U2 firmware uses the standard
USB COM drivers, and no external driver is needed. However, on Windows, a .info file is
required. The arduino software includes a serial monitor which allows simple textual data to be
sent to and from the arduino board. There are two RX and TX LEDs on the arduino board which
will flash when data is being transmitted via the USB-to-serial chip and USB connection to the
computer (not for serial communication on pins 0 and 1). A Software Serial library allows for
serial communication on any of the Uno's digital pins. The ATmega328P also supports I2C
(TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of
the I2C bus.
3.3.2 Atmega328
The Atmega328 is a very popular microcontroller chip produced by Atmel. It is an 8-bit
microcontroller that has 32K of flash memory, 1K of EEPROM, and 2K of internal SRAM.
The Atmega328 is one of the microcontroller chips that are used with the popular
Arduino Duemilanove boards. The Arduino Duemilanove board comes with either 1 of 2
microcontroller chips, the Atmega168 or the Atmega328. Of these 2, the Atmega328 is the
upgraded, more advanced chip. Unlike the Atmega168 which has 16K of flash program memory
and 512 bytes of internal SRAM, the Atmega328 has 32K of flash program memory and 2K of
Internal SRAM.
Fig.3.11: Pin Diagram
Specifications
The Atmega328 has 28 pins. It has 14 digital I/O pins, of which 6 can be used as PWM
outputs and 6 analog input pins. These I/O pins account for 20 of the pins.
Table No.3.4: Key Parameters of Atmega328
Parameter Value
Flash memory 32 kB
SRAM 2 kB
EEPROM 1 kB
28 or 32 pin: PDIP-28, MLF-28, TQFP-32
Pin count
MLF-32
Maximum operating frequency 20 MHz
External interrupts 2
USB Interface No
USB Speed –
1 PC6 Reset
2 PD0 Digital Pin (RX)
3 PD1 Digital Pin (TX)
4 PD2 Digital Pin
5 PD3 Digital Pin (PWM)
6 PD4 Digital Pin
7 VCC Positive Voltage (Power)
8 GND Ground
9 XTAL 1 Crystal Oscillator
10 XTAL 2 Crystal Oscillator
11 PD5 Digital Pin (PWM)
12 PD6 Digital Pin (PWM)
13 PD7 Digital Pin
14 PB0 Digital Pin
15 PB1 Digital Pin (PWM)
16 PB2 Digital Pin (PWM)
17 PB3 Digital Pin (PWM)
18 PB4 Digital Pin
19 PB5 Digital Pin
20 AVCC Positive voltage for ADC (power)
21 AREF Reference Voltage
22 GND Ground
23 PC0 Analog Input
24 PC1 Analog Input
25 PC2 Analog Input
26 PC3 Analog Input
27 PC4 Analog Input
28 PC5 Analog Input
Since the ADC for the Atmega328 is a 10-bit ADC, meaning it produces a 10-bit digital value, it converts
an analog signal to its digital value, with the AREF value being a reference for which digital values are
high or low. Thus, a portrait of an analog signal is shown by this digital value; thus, it is its digital
correspondent value. The last pin is the RESET pin. This allows a program to be rerun and start over. And
this sums up the pin out of an Atmega328 chip.