AZ-Micro Controller Atmega328P Board_EN
AZ-Micro Controller Atmega328P Board_EN
Have fun!
Table of Contents
Introduction....................................................................................................3
Specifications................................................................................................4
Pinout............................................................................................................5
AZ-Micro Controller.......................................................................................6
Communicaton interfaces............................................................................11
Power Pins..................................................................................................12
Power, Current and Voltage Limitations......................................................13
Pins description...........................................................................................16
I/O pins....................................................................................................17
Serial communication pins.......................................................................17
Analog pins..............................................................................................17
I2C pins....................................................................................................18
SPI pins...................................................................................................18
AREF pin.................................................................................................19
On-board LED..........................................................................................19
How to set-up Arduino IDE..........................................................................20
Sketch examples.........................................................................................24
Blinking LED............................................................................................24
PWM - Pulse Width Modulation...............................................................25
-2-
Introduction
There are endless code and library examples already written and available
online. Also there are numerous other microcontroller compatible boards,
like shields, or many sensors built that are easily connected to the
microcontroller board.
-3-
Specifications
Operating voltage 5V
Input voltage (recommended) 7-12V
DC input voltage (limit) 6-20V
Digital I/O pins 14 (6 PWM Ouputs, 6 PWM Digital I/O)
Analog inputs 6
DC current per I/O 20mA
DC current for 3.3V pin 50mA
Flash memory 32KB (bootloader 0.5KB, SRAM 2KB)
EEPROM 1KB (ATMega328P)
Clock speed 16MHz
Built in LED connected to I/O pin 13
Dimensions 69x54x15mm (2.7x2.1x0.5in)
-4-
Pinout
The AZ-Micro Controller has 44 pins. The pinout is shown on the following
image:
-5-
AZ-Micro Controller
-6-
The board features DC voltage regulators for both, +5V and +3.3V. External
DC power supply can be connected to the DC power jack on board with
voltage in range from 7V up to 12V, and voltage regulators will lower and
stabilize it to the +5V and +3.3V.
-7-
Microcontroller board is built in a way that separates digital input/output pins
from analog input pins. So there are 6 analog input pins, and separated 14
digital input/output pins. 6 of 14 digital input/output pins can be used as
PWM outputs (Pulse Width Modulation). Those pins are labeled with tilde
sign “~” (D3, D5, D6, D9, D10, and D11).
Digital input/output pins 0 and 1 are connected to receive and transmit lines
of USART serial interface respectively. It is suggested never to use these
digital I/O pins as digital inputs or outputs, because serial interface is used
every time when new program is uploading to on-board microcontroller or
the microcontroller sends data to the Serial Monitor of the Arduino IDE.
Using these pins as digital inputs or outputs can get many errors while
reprogramming, or when electronic parts or devices are connected to, they
will work incorrectly.
-8-
Onboard ATMega328P there is RESET button for main microcontroller,
ICSP connector is used when ATMega328 is programmed externally via
some other programmer.
-9-
ATMega328P Board features 2 more additional pins, SDA and SCL, which
are connected to the A4 and A5 pins respectively. These pins (A4 and A5)
are used in I2C interface communication (the I2C is also called: TWI - Two
Wire Interface).
- 10 -
Communicaton interfaces
The digital I/O pins D0 and D1 have alternative functions. They are
connected to receive and transmit lines of serial interface.
For SPI interface digital I/O pins D10, D11, D12 and D13 are used. Their
functions are SS, MOSI, MISO and SCK respectively.
For I2C interface analog input pins A4 and A5 are used, or two additional
pins SDA and SCL. Their functions are SDA and SCL respectively.
- 11 -
Power Pins
VIN - This is voltage input pin and serves as another external power supply
for main microcontroller when it is not powered by USB port.
GND - Ground
5V - +5V voltage output
3.3V - +3.3V voltage output
RES - RESET, connecting this pin to GND (LOW) resets the main
microcontroller.
- 12 -
Power, Current and Voltage Limitations
Voltage limits:
Suppling the micro controller board with power can be done either through
USB port, DC Power jack or through power pins header at VIN pin.
When powering the microcontroller board via DC Power jack or VIN and
GND pins, it has the following input voltage limitations:
- 13 -
Voltage limits on input/output pins: -0.5 to +5.5V max. Before reading a
voltage on the microcontroller board or from digital or analog input, ensure it
is between 0 and 5V. If it is outside these limits, bring down the voltage
using a voltage divider. This scales the input voltage to allow for analog or
digital readings of voltages otherwise outside the allowed range. If input
signal is digital, and it is not needed to take scaled analog readings, another
technique is to clip (cut the top off) the input voltage, rather than scale it.
Since AVR microcontrollers have internal clamping diodes, this can be done
by simply adding a single resistor in series with the pin. By adding a 10kΩ
resistor in series with the input pin (any input pin) permits input voltages as
low as - 10.5V or as high as +15.5V.
NOTE: If not powered by USB, the total 5V current limit coming out of the
microcontroller board is limited by the on-board voltage regulator, and/or
input power supply, whichever provides less power. Assuming the power
supply is going to the microcontroller board can provide 7-12V and >= 1A. If
this is the case, the 5V power is limited strictly by on-board voltage
regulator.
- 14 -
Total max current draw across the microcontroller board 5V pin and GND:
as specified above.
Total max current per input/output pin: 40mA.
Sum of currents out of ALL input/output pins combined is: 200mA!!!
NOTE: This is the one that usually gets people, as it may be the least
understood! Despite the fact that voltage regulator on-board the
ATMega328P may permit up to 1A draw across the 5V and GND pins, the
sum of all currents going into or out of the input/output pins (all Analog and
Digital pins combined) of the ATMega328P microcontroller itself cannot
exceed 200mA. So, if powering 10 LEDs at 20mA each, via Analog or
Digital pins, the limit is hit! Any more than that and the damage may occur to
microcontroller. A work around if more current is needed, is to use
transistors. The microcontroller board input/output pins can then use a very
low current to activate a transistor, which then turns a higher current on and
off from the 5V pin directly (which is connected straight to the output of the
on-board linear voltage regulator), to the device you want to control. This
way, the sum of total output from analog/digital pins is kept below 200mA,
while allowing up to the 500mA-1A limit from the 5V pin.
- 15 -
Pins description
The VIN is the input voltage supplied to the board which ranges from 7V to
20V. The voltage provided by the power jack can be accessed through this
pin. However, the output voltage through this pin to the board will be
automatically set up to 5V.
There are 5 ground pins available on the board which makes it useful when
more ground pins are required for a project.
The Reset pin is used to reset the board. Setting this pin to LOW will reset
the board.
- 16 -
I/O pins
Serial pins RXD and TXD are used to transmit and receive serial data. The
Rx represents the transmission of data while Tx is used to receive data.
Analog pins
- 17 -
I2C pins
SPI pins
The SPI stands for Serial Peripheral Interface used for the transmission of
data between the controller and other peripheral components. Four pins
12(MISO), 11(MOSI), 13(SCK), 10(SS) are used for SPI communication.
- 18 -
AREF pin
On-board LED
This board comes with built-in LED connected to digital pin 13. HIGH value
at this pin will turn the LED on and LOW value will turn it off. Simple Blink
and Fade examples from the Arduino IDE can be used for testing the
ATMega328P for the first time.
- 19 -
How to set-up Arduino IDE
If the Arduino IDE is not installed, follow the link and download the
installation file for the operating system of choice. The Arduino IDE version
used for this eBook is 1.8.15.
For Windows users, double click on the downloaded .exe file and follow
the instructions in the installation window.
- 20 -
For Linux users, download a file with the extension .tar.xz, which has to
be extracted. When it is extracted, go to the extracted directory and open
the terminal in that directory. Two .sh scripts have to be executed, the first
called arduino-linux-setup.sh and the second called install.sh.
To run the first script in the terminal, open the terminal in the extracted
directory and run the following command:
sh arduino-linux-setup.sh user_name
user_name - is the name of a superuser in the Linux operating system. A
password for the superuser has to be entered when the command is
started. Wait for a few minutes for the script to complete everything.
The second script, called install.sh, has to be used after the installation
of the first script. Run the following command in the terminal (extracted
directory): sh install.sh
After the installation of these scripts, go to the All Apps, where the Arduino
IDE is installed.
- 21 -
Almost all operating systems come with a text editor preinstalled (for
example, Windows comes with Notepad, Linux Ubuntu comes with
Gedit, Linux Raspbian comes with Leafpad, etc.). All of these text
editors are perfectly fine for the purpose of the eBook.
- 22 -
If the Arduino IDE is used on Windows, port names are as follows:
- 23 -
Sketch examples
Blinking LED
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
- 24 -
PWM - Pulse Width Modulation
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}
- 25 -
Now is the time to learn and make the Projects on your own. You can do
that with the help of many example scripts and other tutorials, which can be
found on the internet.
https://az-delivery.de
Have Fun!
Impressum
https://az-delivery.de/pages/about-us
- 26 -