Introduction to Arduino Micro

Hey Guys! Hope you are getting along with life pretty well. Welcome you onboard. Today, I'll unlock the details on the Introduction to Arduino Micro. It is a Micro board, based on the ATmega32U4 microcontroller and comes with built-in USB, making it easily compatible with the computer. Arduino Micro, as the name suggests, is the smallest board in the Arduino Community. It is comparable to its counterparts like Arduino Nano and Arduino Promini. In this tutorial, I'll discuss each and everything related to Micro board including its main features, pinout, pin description, the software used and applications. Let's dive in and explore everything you need to know about this tiny board.

Introduction to Arduino Micro

  • Arduino Micro is the smallest board in the Arduino Community and is mainly based on the ATmega32U4 microcontroller.
  • It contains a built-in USB on the tiny easy to integrate interface, that helps in laying out a prompt connection with the computer.
  • Don't get into the illusion of performing complex functions that require more memory space, as this little toy comes with flash memory around 32 KB while EEPROM and SRAM are 2.5 KB and 1 KB respectively, still enough to wet your technical appetite.
  • The maximum length and width of the Micro PCB are 4.8cm and 1.77cm respectively, however, with the attached USB port the dimensions will slightly be larger than the given parameters, exceeding from the edge of the PCB layout.
  • Breadboard compatibility makes this device easy to use for getting a hands-on experience before incorporating it in the relevant project with all prerequisites.
  • You can download Arduino Micro Datasheet by clicking below button:
Download Arduino Micro Datasheet
  • The ATmega32U4 microcontroller available on the board features UART communication with TX and RX pins.
  • The Micro board incorporates resettable poly-fuse that that is mainly used for securing computer's USB ports from shorts and overcurrent by providing an extra layer of protection.
  • If the current escalates from the required value to the USB port, the fuse will jump in and work as an emergency switch, breaking the connection between the board and computer. It is advised to keep the provided current to the USB port under 500mA.

1. Arduino Micro Features

If you are aiming to pick this Arduino module for your relevant project, it is advised to get a hold of its features in order to avoid any hassle in future. The following figure shows the main features of Arduino Micro.
Microcontroller ATmega32U4
CPU 8-Bit
Digital I/O Pins 24
PWM Output 7
Analog Input 12
Flash Memory (Program Memory) 32 KB
SRAM 2.5 KB
EEPROM 1 KB
Input Voltage 7-12 V
Operating Voltage 5 V
Oscillator up to 16 MHz
Software Used Arduino Software (IDE)
Reset Button Yes
ICSP Header Yes
USB Port 1
UART (Serial Communication) Yes
  • Serial communication along with SPI and I2C communications are available on the board. The physical reset button is added that helps to stop the running function and puts the controller in the initial condition from where it takes and implements the stored information from scratch.

2. Arduino Micro Pinout

Following figure shows the Arduino Micro Pinout diagram.
  • You may have heard, at times, tiny things work wonders. Same is true with this module. It is nothing but a technical peripheral device with a number of features laid out and housed in one package.
  • Still, as I have mentioned earlier, it operates perfectly if you plan to design the simple project that requires less memory space. Arduino Due and Arduino Leonardo are preferred to meet your technical needs if your project requirements are complex and require more memory space in order to design and drive automation in the relevant project.
  • The built-in USB communication on the board removes the need for a secondary processor and helps it to appear to a connected computer as a keyboard and mouse, in addition to a virtual (CDC) serial / COM port.

3. Arduino Micro Pin Description

Until now, you have got a brief overview of this device and how this module can be a good fit for your project. In this section, I'll discuss the pin description with images, you can easily grab the idea what are the major functions associated with each pin. Let's get to the point.
Analog Input
There are 12 analog inputs on the board. You can see them in the figure below.
Communication Protocols
Communication protocols like serial, SPI and I2C are incorporated on the board. You can see them highlighted on the figure below.
PWM Output
Seven pins are used for PWM output purpose. It is a process for getting analog results with digital means. You can see PWM in the figure below.
Power Source
The 5V is a voltage at which board operates while 3.3V is the operating voltage of each pin. The Vin is the input voltage that ranges between +7 to +12 V and is a  voltage from the external power source, not from a USB port. There are two ground pins on the board. The AREF predicts the Analogue reference voltage that helps to inject the Arduino a reference voltage from an external power supply. You can see the power source in the figure below.
External Interrupt
PCINT are the external interrupts generated on any digital I/O pin. The following figure shows the pins on which external interpret can be generated.
ICSP Header Pins
ICPS head is added on the board and it stands for In-Circuit Serial Programming - A feature used for programming Arduino with another Arduino. And if USB port is not available, it comes out handy for connecting the board with a computer for uploading a sketch.

4. Programming

  • Arduino Software, called IDE, is mainly used for programming the Arduino module and it works perfectly with common operating systems like Windows, Linux or MAC. You can download it from the Arduino site and it is compatible with all versions in the Arduino family.
  • You are ready to use the software as you install it. Some simple LED programs are already available on the software so you can easily start working on the board and compile the default program with the intention you are getting the results on the fly.
  • Built-in bootloader that comes with the board lets you off the hook from wresting your mind for compiling and burning the code using the external burner.
  • Micro board features a serial peripheral interface (SPI) that is mainly used in the communication between the microcontroller and other peripheral devices such as shift registers and sensors. Two pins are used for SPI communication i.e. MOSI (Master Output Slave Input) and MISO (Master Input Slave Output) - they are used for sending and receiving the data by the microcontroller.
  • The Serial Monitor is added in Arduino Software, that plays a vital role in transmitting textual data to or from the board.
  • The TX and RX pins are used for serial communication where TX pin transmits the serial data while RX receives the serial data.
  • The board is capable to perform I2C communication using two pins called SDA and SCL.

5. Difference between Arduino ProMini and Arduino Micro

  • There is a little difference between Arduino ProMini and Micro board, however, peripherals on these boards are same.  The built-in USB in the Micro board proves to be a candid difference between two modules while Promini requires FTDI cable in order to generate USB power and communication to the board.
  • The USB on Micro board can act as a number of ways: Keyboard or mouse, USB hard drive, USB to serial Converter and MIDI controller.
  • The Arduino Pro Mini incorporates ATmega328 microcontroller while Arduino Micro comes with ATmega32U4. Flash memory is the same on both modules however, SRAM differs slightly with 2KB on the ProMini and 2.5 KB on the Micro board.
  • Last not least, the Arduino Pro Mini features 2 hardware interrupts while the Micro board comes with 5 hardware interrupts.

6. Arduino Micro Projects and Applications

Arduino micro comes with a wide range of applications with the ability to groove in hard to reach places. It offers a high number of connections with a minimum interface. The outstanding ability of this board to disguise keyboard or mouse while connected with a computer makes it an ideal choice for many computer applications. You can use this board for the development of the following projects.
  • USB Joystick
  • Electric Bike
  • Windows PC lock/unlock application
  • Creating wireless keyboard
  • Automatic Pill Dispenser
  • USB Trackpad
  • Water Level Meter
There is a list of projects you can create but I have mentioned a few of them to give you an idea what this tiny thing can help in designing a product ranging from embedded, automation to computer applications. That's all for today. I hope I have given you everything you needed to know about Arduino Micro. However, if you are unsure and consider something is left unsaid, making it difficult for you to grab the basic idea, you can approach me in the comment section below. I'd love to help you the best way I can. Keep your feedback and suggestions coming and help us create a quality content as per your needs and requirements. Thanks for reading the article.

Introduction to Arduino LilyPad

Hi Friends! Hope you are doing well. Today, I'll give you a detailed Introduction to Arduino LilyPad. It is an Arduino Microcontroller Board, based on ATmega168/ATmega328 and is introduced by Leah Buechley and SparkFun Electronics.

This board is mainly developed for e-textiles and wearables projects. As per the designed purpose, it can be attached to fabric, sensors, power supplies, and actuators. You may need a conductive thread for joining this board with the required object.

In this post, I'll try to cover each and everything related to Arduino LilyPad, what is this about and how it is used for the development of desired projects. Let's jump right in and get down to the nitty-gritty of this board.

Where To Buy?
No.ComponentsDistributorLink To Buy
1Arduino LilypadAmazonBuy Now

Introduction to Arduino LilyPad

  • Arduino LilyPad is an Arduino Main Board that is mainly designed for e-textiles and wearables projects and is based on the Atmega168/Atmega328 microcontroller.
  • LilyPad is nothing but an Arduino-programmed microcontroller and works similar to other Arduino boards available.
  • It comes in a round shape unlike other Arduino boards so that it could fit easily in wearables.
  • However, the ability of this board to be sewn down with the fabric or sensor through conductive thread puts it ahead and stands out of the boards available in the Arduino community.
  • There are 22 wide open pin-holes, appear around the edge of the whole rounded shape that is mainly used for the connection with the fabric and sensor through a conductive thread.
  • Out of these 22 pinholes, one is reserved for +5V, and one for ground.
  • The LilyPad Arduino incorporates 6 analog inputs that can also be used as digital I/O. They are marked as A0 through A5 on the board, providing 10 bits of resolution. It is important to note that, the analog inputs measure from ground to 5 volts, however, the upper end of their range can be modified using the analogReference() function.
  • The board contains 14 digital pins that can be employed as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions.
  • Like other boards in the Arduino, this Pad is programmed by Arduino IDE - an official software mainly used for programming the Arduino Boards, that is developed by Arduino.cc
  • The board comes with a wide voltage range and operates anywhere between 2.7 V to 5.5 V. The pins on the board come with the ability to control and handle the input or output of the attached device.
  • There are two ways to keep your Pad null and void: increase the operating voltage above 5.5 V or plug the power in reverse order.
  • As I mentioned earlier bootloader is used for storing the code and burning it on the board, however, you can also bypass the bootloader and program the ATmega328 using ICSP (In-Circuit Serial Programming) header.

Arduino LilyPad Features

Following are the main features of the Arduino LilyPad.
Microcontroller ATmega168 or ATmega328V
Digital I/O Pins 14
Analog Input Channels 6
PWM Channels 6
Crystal Oscillator 8 MHz
Flash Memory 16 KB (of which 2 KB used by bootloader)
Bootloader Memory Out of 16KB in the Flash Memory, 2KB is reserved for Bootloader
SRAM1 KB 1 KB
EEPROM 512 bytes
Operating Voltage 2 to 5 V
DC Current per I/O Pin 40 mA
Internal pull-up resistor 20 kO

Arduino LilyPad Pinout

  • Arduino Lilypad Pinout is shown in the below figure:
  • There is a candid difference between external interrupt pins and PCINT pins. Former is the dedicated hardware pin used for generating the interrupt while later is the interrupt that can be created on any digital I/O pin.
  • There are 6 PWM tabs on the board, shown by the dashed lines on the pinout image above. These PWM pins can also be used as digital I/O pins.

How to program Arduino LilyPad?

You can layout the LilyPad connection by following the given steps.
  • Be careful while connecting the power and ground pins of the board. The +5V power must be connected to the positive tab on the board and the ground tab of the board should be connected to the ground of the power source. The reverse connection can cause severe damage to the board and in a worst-case scenario, your board may stop working all at once.
  • There are two ways to generate a regulated +5V power source: Using a +5V pin of the Mini USB Adapter or employing another 2.7-5.5V power source using a Lithium rechargeable battery.
The following figure shows the LilyPad connection with Mini USB Adapter:
  • You can see the two circular tabs on the board marked as TX and RX that are mainly used in two ways: For uploading new sketches to the board and establishing a serial communication with other devices.
  • Apart from using your own power supply, you can also use Mini USB Adapter or Arduino NG board for connecting the Pad with the computer.

The following figure shows the connection of the Arduino UNO with LilyPad:

Note: Don't forget to remove the ATmega8 or ATmega168 from the NG before connecting it with the LilyPad. You can use alligator clips and jumper wires for connecting the +, -, TX and RX tabs on the LilyPad with the corresponding pins on the NG board.

Applications

  • LilyPad is really very handy for e-textile and wearable products, because of its small size.
  • Arduino Lilypad is used in IoT products and embedded projects as well.
  • The circular tabs covering the whole Pad at the edge are mainly used for the connection between Pad and wearable products.

That's all for today. I hope this read has succeeded in grappling your attention and resonated with your field of interest. If you are feeling dubious in any area of the information related to the Pad that I have left unfolded, you can approach me in the comment section below. I'd love to help you according to the best of my expertise. Keep visiting us for valuable information related to engineering and technology. Thanks for reading the article.

How to use digitalWrite Arduino Command

Hey Friends! Hope you are doing well. Today, I'll discuss the details on How to use digitalWrite Arduino Command. The digitalWrite command in Arduino is used for writing the status of the digital Pin. The Pin assigned to this command must be an OUTPUT pin so that it can transfer data to other components like LEDs, motors, and actuators and use them as per your needs and requirements. Arduino boards have always been a great choice for both experts and newbies, as they come with built-in peripheral functions, and no need of external components is required to drive automation and develop some basic functions on the relevant project. Basic Arduino Software is used as a compiler and no separate burner is required to burn the required code into the board. You can simply plug the board with the computer through a USB cable and burn and compile the program by a single click on the software.

How to use digitalWrite Arduino Command

  • digitalWrite Arduino Command is used to write the status of digital Pins, and can make them either HIGH or LOW. The Pin needs to be an OUTPUT Pin.
  • We are working on Arduino UNO, that comes with 14 digital I/O pins and 6 analog pins. You can set these pins as an input or output using pinMode based on your technical requirements.
  • These pins are labeled as 0 to 13 on the board including two serial pins called Tx and Rx appearing at the start and marked as 1 and 0 pins respectively.
  • We set Pins as an INPUT when we want to read or receive data from some component like sensors. And making pins as an OUTPUT will require a digitalWrite function to write or send data to the required device like LEDs, motors etc.
  • When any pin is set an as OUTPUT using the pinMode Arduino Command, it will appear as HIGH or LOW depending on the voltage applying on the pin. For voltage above 3.3V it will appear as HIGH and for GND (ground) it will appear as LOW on the software.
  • Before connecting an LED to pin, make sure to set pinMode as OUTPUT when you call the digitalWrite function, otherwise LED won't be flashing with clear bright light.
Syntax for digitalWrite Arduino
  • Here’s the syntax used for digitalWrite Arduino command:

digitalWrite(pin, value);

where:
  • The "pin" defines the Arduino pin number used. It has to be an OUTPUT Pin.
  • And "value" defines if the pin will be HIGH or LOW.
  • For example:

digitalWrite(8, HIGH);

Note: 
  • It is worth mentioning here that digitalWrite command doesn’t store or return any value unlike most of the commands used in Arduino that help in storing some value.
Difference between analogWrite and digitalWrite
Both terms analogWrite and digitalWrite are used for same purpose i.e. sending data from Arduino, but:
  • The former is used to send data in analog form i.e. 0V - 5V.
  • The later only defines the HIGH and LOW value of the desired pin where HIGH is an indication, pin is getting 5V and LOW is an indication pin is set to ground or zero voltage.
That's all for today. I hope you have found this article informative. If you are unsure or have any question, you can ask me in the comment section below. I'd love to help you according to the best of my expertise. You are most welcome to keep us updated with your valuable feedback and suggestion - they help us provide you quality work so you keep coming back every now and then. Thanks for reading the article.

How to use pinMode Arduino Command

Hi Friends! Hope you are doing well. In this post, I'll uncover the details on How to use pinMode Arduino Command. The pinMode defines the Arduino Pins, if they are used as an input or output. The INPUT_PULLUP is another option achieved by pinMode, that is mainly used to place a virtual pull-up resistor to the input pins. We have started Arduino Tutorials for Beginners quite a while now for the newbies, who are really interested to get a hands-on experience with Arduino. Generally, Arduino is known as a Microcontroller, but it is a step ahead of it. The PIC microcontrollers require some basic circuit to start with but Arduino brings revolution in the automation industry by removing the need of developing any basic circuit. Although Atmega328 is the Microcontroller used in Arduino UNO. Also, the burner is required to burn the program in PIC Microcontrollers, while there is no need to connect separate burner with the Arduino - simply plug it with the computer through a USB cable and start playing with it. In this tutorial, we will thoroughly discuss what is pinMode and how to use it in the Arduino module. Let's jump right in and explore what is this about and everything you need to know.

How to use pinMode in Arduino

  • The Arduino Board comes with GPIO (general purpose input output) pins that can be used in two ways i.e. input, output.
  • pinMode Arduino Command is used to define the operation of these Input/output pins, there are three types of modes that can be assigned using this command and are named as:
    • OUTPUT.
    • INPUT.
    • INPUT_PULLUP.
  • There are 14 digital and 6 analog pins in the module that mainly depend on the pinMode for setting up their mode of operation as an input or output.
  • In this post we mainly discuss the Arduino UNO, that is based on ATmega328 microcontroller, however, you can use other modules like Pro Mini, Mega or Leonardo as per your needs and requirements. The pinMode works same in the module no matter what type of Arduino version you are using.
Syntax for pinMode Arduino
Here's the syntax for our pinMode Arduino command:

pinMode(pin#, mode);

where:
  • Pin defines the Arduino pin number used.
  • There are three types of modes that can be assigned to pins of Arduino, which are:
    • OUTPUT
    • INPUT
    • INPUT_PULLUP
Let's use Pin # 8 of Arduino and assign all possible modes to it:

pinMode(8, OUTPUT);

pinMode(8, INPUT);

pinMode(8, INPUT_PULLUP);

Note: 
  • It is important to note that, unlike most of the functions used in the C code for Arduino module, this pinMode doesn't store or return any value.
  • You have to use any one of these three modes at a time.
Modes of pinMode Arduino
  • In the previous section, we have discussed the basic syntax of pinMode, and I hope you have pretty much got the basic idea behind it.
  • The only thing worth mentioning here is the difference between INPUT and INPUT_PULLUP.
  • So, here's a simple code where I have made Pin # 8 as an INPUT and read its status on Serial Monitor.
int Pin = 8;

int Status = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(Pin, INPUT);          
}

void loop()
{
  Status = digitalRead(Pin);       
  
  if(Status == HIGH)
  {
    Serial.println("HIGH");
  }

  if(Status == LOW)
  {
    Serial.println("LOW");
  }
 
}
  • Let's have a look at the Serial Monitor:
  • While taking the above image, Pin # 8 was in open state and we are getting just random values.
  • We are getting these random values i.e. HIGH, LOW because our Pin#8 is neither connected to +5V nor GND.
  • Arduino seems confused here, and we can remove this confusion by simply changing INPUT to INPUT_PULLUP.
  • As we run the Serial Monitor, we will get something shown below:
  • You can see how we are getting HIGH value only, while the pin is still in open state.
  • We can conclude, when we have nothing on our INPUT pin then INPUT_PULLUP will make the pin HIGH.
Difference between Read and Write
There are two ways to send or receive data. You can either define the pin as an input that helps in reading the data from an external device like sensors. Or you can define pin as an output that helps in writing and sending a command to LEDs, motors or actuators for executing the desired functions. That's all for today. I hope you have found this post informative as per your needs and requirements and can easily use this pinMode Arduino Command. If you are feeling skeptical or have any question, you can ask me in the comment section below. I'll try and help you according to the best of my expertise. Thanks for reading the article.

Introduction to Arduino Due

Hey Fellas! I am back to give you a daily dose of useful information. Today, I'll uncover the details on the Introduction to Arduino Due. It is a microcontroller board based on Atmel SAM3X8E, 32-Bit ARM microcontroller. It is developed by Arcuino.cc with the intention to provide an easy pathway for the beginners to get a hands-on experience with the module without any prior technical knowledge. You can just plug the device into the computer through a USB cable and start playing with it right away. Arduino Modules are a step ahead of a single microcontroller. If your project is mainly based on a microcontroller, you need to buy external peripherals and connect them with the controller in order to lay out an automation into your project. Arduino Boards has made things easy more than ever before. Although, more or less, they are known are microcontrollers, they have a leg over them because of built-in peripherals and an ability to perform a number of functions on a single chip. Also, no external burner is required for Arduino, as it comes with a built-in burner. You just have to write and compile the required code into the Arduino Software and burn in the module through a single click on the computer. In this post, I'll cover each and everything related to Arduino Due i.e. its main features, pinout, pin description, compilers used and applications. Let's get down to the nitty-gritty of this tiny module and explore everything you need to know.

Introduction to Arduino Due

  • Arduino Due is a microcontroller board that is mainly based on Atmel SAM3X8E (32-Bit ARM microcontroller). It is a big module as compared to Arduino Nano or Arduino Uno and comes with more number of pins and memory space as compared to them.
  • It contains 54 digital that can work both ways: input or output. Out of these digital pins, 12 can be used to generate PWM outputs.
  • This module contains everything in bulk required for the automation project including 12 analog inputs, and 4 UARTs serial module.
  • I was floored when I came to know this module comes with clock frequency around 84 MHz. Yes, you heard that right. The splendid oscillator will help in processing speed grow skyrocket.
  • Two USB ports are available where one is used as a programming USB Port while other is Native USB Port. Don't you worry, I'll make it clear the difference between them. Just follow along.
  • Most of the Arduino Boards run at 5 V but this module is an exception that operates at 3.3V. The pins incorporated on the cannot withstand voltage higher than this. Doing so can drastically affect the board performance and can make your pins null and void.
  • JTAG is added on the board that is mainly used for testing the physical connection between the onboard pins.
  • The Arduino Due can be programmed using a common Arduino Software (IDE), that is compatible with all Arduino boards and can work both ways: online and offline.
  • This module incorporates 2 DAC (digital to analog), 2 TWI, a power jack (you can power up the device by connecting it with a computer through USB cable or using this power jack), an SPI header reset button, an erase button and reset button. Bunch of functions, making your task easy.
  • As per the voltage constraint, Arduino shields that operate at 5V are not compatible with this Due module. However, the shields that come with Arduino R3 layout work efficiently including Arduino WiFi shield and Ethernet Shield as they operate at 3.3V.

1. Arduino Due Features

You have got a brief overview of the device. I have compiled the main features of this device at one place. Following table shows the main features of Arduino Due.  
Microcontroller Atmel SAM3X8E ARM Cortex-M3
CPU 32-Bit
Digital I/O Pins 54
PWM Output 12
Analog Input 12
Flash Memory (Program Memory) 512 KB
SRAM 96 KB (two banks: 64 KB and 32 KB)
Operating Voltage 3.3V
Input Voltage 7-12 V
Manufacturer Arduino.cc
Oscillator up to 84 MHz
Software Used Arduino Software (IDE)
Reset Button 1
Erase Button 1
DAC (Digital to Analog Converter) 2
UART (Serial Communication) 4
SPI Communication Yes
TWI (I2C Communication) 2
Arduino Shield Compatibility Yes (that operate at 3.3V)
USB (2) Programming USB (1) Native USB (1)
Power Jack 1
JTAG Header 1
DC current for 3.3V 800mA
Total DC output current on all I/O lines 130mA

2. Arduino Due Pinout

Now, you have got a hold of the main features of this module. In this section, I'll highlight the pinout of the chip. Following figure shows the pinout of Arduino Due.  
  • I know it is quite overwhelming and difficult to digest at one glance, but don't you worry I have broken it down in the pin description with images.

3. Arduino Due Pin Description

The function associated with each pin will help you understand the purpose of each pin in the relevant project they can be used for. Following table shows the description of each pin.
Digital I/O Pins 54 There are 54 digital I/O pins, out of which 12 can be used as PWM outputs.
Analog Pins A0 to A11 These pins are used for an analog pins on the board. They are 12 in numbers.
Digital to Analog Converter DAC0, DAC1 Two digital to analog converter with 12bit resolution.
Erase Button 1 Erases the information by holding down this button
Reset Button 1 Resets the board
External Interrupts Digital I/O Pins All 54 pins can be used for generating an external interrupt
UART 4 Board comes with 4 pairs of TX and RX serial pins for laying out serial communication. These pins include (A9,A8), (D4,D5), (A13,A12), (A11,A10)
SPI Serial Peripheral Communication (MOSI, MISO, SCK, RESET) Pin used (A26, A25, A27, Reset)
TWI Two Wire Interface (2 module) There are two I2C communication incorporated on the board with pins at A18, A17, B13, B12
CAN Interface 2 CAN (Controller Area Network) Interface is used for communication between controllers. Pins include
Power Source +5V, +3.3V, GND and Vin +5V- Connected to 5V +3.3V (Operating Voltage) Vin- Input Voltage - Connected to +7V to +12V (recommended) GND - Connected to Ground
  You have got clear about the functions associated with each pin. Now, I'll highlight the functions of each pin with images, making it easy for you to look at the information without much hassle.
Digital I/O Pins
Arduino Due comes with four ports named PORTA, PORTB, PORTC, and PORTD. There are 54 digitals I/O pins. The pins with PINK color on the pinout mention above are used as digital I/O pins.
Analog Pins
There are 12 analog pins on the board. They are a part of PORTA and PORTB and appear on the board as follow.  
USB Ports and Power Jack
There are two USB ports available on the board where one is programming USB port and other is native USB port. Both ports can be used for programming purpose, however, the native port also acts as a USB host for connected peripherals like keyboards and smartphones. There is one power jack on the board for powering up the device.
UART
There are four UART channels added on the board. They are used for the serial communication with the external devices where TX is the Serial Transmit Pin while RX is the Serial Receive Pin. They appear on the board as follow.
TWI
There are two TWI (Two Wire Interface) modules incorporated on the board, also known as the I2C protocol, and are used to establish the communication between low-speed devices like ADC and DAC converters and microcontrollers. It is a two wire communication and comes with two lines: Serial Clock (SCL) and Serial Data (SDA). The former is a clock signal that is used to synchronize the data transfer between the devices while the later is used to hold the desired data.
PWM Output
Out of 54 digital pins, 12 are used for PWM output. They appear on the board as follow.
JTAG Header
JTAG header is a remarkable addition in the board that most of the board lack in the Arduino Community. It is a common hardware interface that sets a pathway to communicate directly with external chips on a board. It was introduced by the Joint (European) Test Access Group with the intention of testing the physical connections between pins on a chip. It comes with fours pins known as TCK, TMS, TDI, and TDO. This header incorporates on the board as follows.
Reset and Erase button
There is one reset and one erase button is added on the device. Former is used to reset the controller while later is used to erase the stored information on the board. They appear on the board as follow.
Power Source
There are four power sources mentioned as 5V, 3.3V, Vin and Ground. The 3.3V is the operating voltage of each pin while Vin is the input voltage with the recommended voltage range of 7V to 12V. You can power the controller with Vin or 5V. These voltage sources appear on the board as follow.
4. Programming and Communication
  • Almost all Arduino Boards can be programmed by Arduino Software called IDE. It is easy to use and a common person with no prior technical can learn the software without much difficulty. It is readily available, just download the software and select the board you aim to work on. As I mentioned earlier, no external burner is required to burn the code into the controller. Arduino software works perfectly with common operating systems like Windows, Linux or MAC.
  • This module comes with a bunch of communication protocols to communicate with external devices. The UART is useful for setting up a serial communication. One serial module is okay, right? Wrong. There are four of them, giving you the flexibility to establish serial communication with more than one devices. Serial library in the software is mainly used for the serial communication between board and external devices.
  • The Serial Monitor is a remarkable addition in Arduino Software, mainly used for transmitting textual data to or from the board.
  • The TX and RX pins incorporate an LED on each pin that flashes as the data is transmitted.
  • Two Wire Interface is also included in the device that comes with two lines SDA and SCL. There are two TWI channels available on the board. Arduino Software Wire Libary is used to access the TWI bus.
  • Arduino Due comes with a serial peripheral interface (SPI) that plays a vital role in the communication between the microcontroller and other peripheral devices such as shift registers and sensors. There are two pins used for SPI communication i.e. MOSI (Master Output Slave Input) and MISO (Master Input Slave Output). The former is used for receiving the data while later helps in sending data by the microcontroller.

5. Difference between Arduino Due and Arduino Mega

There is a vital difference between both modules in terms of operating voltage, memory space, number of pins and processing speed. Arduino Due can perform the functions with greater pace as compared to Arduino Mega. More powerful built-in peripherals and more memory space put Arduino Due ahead of Mega. However, there are some limitations. Arduino Due is not compatible with the 3.3V devices, also, SAM3Xchip provides a complex and intimidating interface that can scare the hell of the person who is practicing this module very first time. It is advised to work with a smaller module like Arduino Uno in the start, and as you get a solid grip on the module, you can move to the complex interface.

6. Arduino Due Applications

Arduino Due is a little bit bulky, covers large space and is used in a wide range of applications where fast processing speed is the end result. Following are the main applications of the board.
  • Industrial Automation
  • Home and Security Systems
  • Virtual Reality Applications
  • Android Applications
  • GSM Based Projects
  • Embedded System
That's all for today. I hope I have given you everything you needed to get started with this module. If you are still living in doubt, you can approach me in the comment section below. I'll guide you the best way I can. Your feedback and suggestions are the piece of nuggets for us, on which we generate and shape our content - so keep that coming. Thanks for reading the article.

Introduction to ATmega128

Hey Guys! Hope you are doing well. I am back to feed you with valuable information relating to engineering and technology. Today, I'll uncover the details on the Introduction to ATmega128. It is an AVR, 8-bit low power microcontroller, that comes with a 64-pin interface and is based on RISC architecture.  Availability of 133 Powerful Instructions with single clock cycle and 32 x 8 General Purpose Working Registers make this device an ideal choice for many applications where decent code execution is required. The memory space incorporates on this module is more than normal AVR controllers including Program memory around 128K, enough to store the number of instructions on a single chip. In this post, I'll try to cover each and everything related to ATmega128, so you can get clear idea what is this about before aiming to pick it for your relevant project. Let's jump right in and get down to the nitty-gritty of this module.

Introduction to ATmega128

  • ATmega128 is an AVR, 8-bit low power microcontroller that contains 64-pin interface and is based on RISC architecture.
  • It is mainly used in an embedded system and industrial automation.
  • This AVR controller differs from PIC controllers in accordance with the instruction set where AVR requires one clock cycle to execute a number of instructions while PIC controllers need a number of clock cycles to execute a single instruction.
  • The ADC is included in the device that makes it an ideal choice for sensor interfacing where it receives the analog signal and converts it to a digital one. There are total 8 channels available on the ADC module.
  • Apart from communications protocols like SPI, I2C, and USRAT, this tiny module comes with watchdog timers, external interrupts, power up timer, 6 sleep modes and programming enable pin.
  • The Program Memory is based on Flash and comes with a memory space around 128K while EEPROM and SRAM are 4K each.
  • If you are an expert or newbie, you need this module every now and then for the development of the electronic projects where automation is a major concern. Ability to perform a number of functions without buying external components makes this device highly economical and best choice for the tech geeks.

1. ATmega128 Features

This AVR microcontroller comes with very useful features. Large memory space and number of pins make this device a step ahead for driving automation in the relevant project. Following table shows the main features of ATmega128.
No. of Pins 64
CPU 8-Bit AVR
Operating Voltage 4.5 to 5.5 V
Program Memory 128K
Program Memory Type Flash
RAM 4K
EEPROM 4K
ADC Number of ADC Channels 10-Bit 8
Analog Comparator Yes
PWM Channels 6
Oscillator up to 16 MHz
Timer (4) 16-Bit Timer (2) 8-Bit Timer (2)
Packages (3) PDIP TQFP QFN
Power Up Timer Yes
I/O Pins 53
Manufacturer Microchip
SPI Yes
I2C Yes
Watchdog Timer Yes
Brown out Detection (BOD) Yes
USART Yes
Sleep Modes 6
Minimum Operating Temperature -40 C
Maximum Operating Temperature 85 C

2. ATmega128 Pinout and Pin Description

The pinout and pin description of each pin will help you understand the major functions associated with each pin. Some pins are able to perform more than one functions on each pin.
Pinout
Following figure shows the pinout of ATmega128.  
  • The AVCC is the voltage applied to the ADC module while AREF is the reference voltage applied to the controller. The VCC and GND are the voltage supply and ground pins respectively.
Pin Description
Following table shows the description of each pin.
1 PEN Programming Enable
2 PE0 RXD PDI I/O Pin Serial Receive Pin (USART)
3 PE1 TXD PDO I/O Pin Serial Transmit Pin (USART)
4 PE2 XCK0 AIN0 I/O Pin External Interrupt PinAnalog Comparator Positive
5 PE3 OC3A AIN1 I/O Pin Dedicated Pin for Timer (PWM Channel) Analog Comparator Negative
6 PE4 OC3B INT4 I/O Pin Dedicated Pin for Timer (PWM Channel) Interrupt
7 PE5 OC3C INT5 I/O Pin Dedicated Pin for Timer (PWM Channel) Interrupt
8 PE6 T3 INT6 I/O Pin Timer 3 Interrupt
9 PE7 ICP3 INT7 I/O Pin Timer/Counter3 Input Capture Pin Interrupt
10 PB0 SS I/O Pin SS (Slave Select Input for SPI).  This pin is set to low when the controller acts as a slave
11 PB1 SCK I/O Pin SCK (Serial Clock for SPI). This clock is shared between the controller and external devices for accurate data transfer
12 PB2 MOSI I/O Pin MOSI (Master Output Slave Input) for SPI communication. The data is received by this pin when the microcontroller acts as a slave
13 PB3 MISO I/O Pin MISO (Master Input Slave Output) for SPI communication. The data is sent to the master using this pin when microcontroller acts as a slave
14 PB4 OC0 I/O Pin PWM Channel Output
15 PB5 OC1A I/O Pin PWM Channel Output
16 PB6 OC1B I/O Pin PWM Channel Output
17 PB7 OC2 OC1C I/O Pin PWM Channel Output
18 PG3 TOSC2 I/O Pin MISO (Master Input Slave Output) for SPI communication. When the controller acts as a slave, the data is sent by a controller to master through this pin Interrupt
19 PG4 TOSC1 I/O Pin SCK (SPI Bus Serial Clock). This clock is shared between the controller and other devices for data transfer Interrupt
20 RESET Voltage Supply Pin for ADC
21 VCC Voltage Reference
22 GND Ground Pin
23 XTAL2 Crystal Oscillator Output
24 XTAL1 Crystal Oscillator Input
25 PD0 SCL INT0 I/O Pin I2C communication External Interrupt 0
26 PD1 SDA INT1 I/O Pin I2C communication External Interrupt 1
27 PD2 RXD1 INT2 I/O Pin Serial Communication Receive Pin (USART) External Interrupt 2
28 PD3 TXD1 INT3 I/O Pin Serial Communication Transmit Pin (USART) External Interrupt 3
29 PD4 ICP1 I/O Pin Timer/Counter1 Input Capture Pin
30 PD5 XCK1 I/O Pin External Clock I/O for USART
31 PD6 T1 I/O Pin Timer 1
32 PD7 T2 I/O Pin Timer 2
33 PG0 WR I/O Pin Control Pin for writing to the external memory
34 PG1 RD I/O Pin Control Pin for reading from the external data memory
35 PC0 A8 I/O Pin
36 PC1 A9 I/O Pin
37 PC2 A10 I/O Pin
38 PC3 A11 I/O Pin
39 PC4 A12 I/O Pin
40 PC5 A13 I/O
41 PC6 A14 I/O Pin
42 PC7 A15 I/O Pin
43 PG2 ALE I/O Pin ALE (Address Latch Enable), it is used when multiple memory chips are connected to the microcontroller and only one of them needs to be selected
44 PA7 AD7 I/O Pin
45 PA6 AD6 I/O Pin
46 PA5 AD5 I/O Pin
47 PA4 AD4 I/O Pin
48 PA3 AD3 I/O Pin
49 PA2 AD2 I/O Pin
50 PA1 AD1 I/O Pin
51 PA0 AD0 I/O Pin
52 VCC Voltage Supply Pin
53 GND Ground
54 PF7 ADC7 TDI I/O Pin ADC Channel 7 JTAG Interface
55 PF6 ADC6 TDO I/O Pin ADC Channel 6 JTAG Interface
56 PF5 ADC5 TMS I/O Pin ADC Channel 5 JTAG Interface
57 PF4 ADC4 TCK I/O Pin ADC Channel 4 JTAG Interface
58 PF3 ADC3 I/O Pin ADC Channel 3
59 PF2 ADC2 I/O Pin ADC Channel 2
60 PF1 ADC1 I/O Pin ADC Channel 1
61 PF0 ADC0 I/O Pin ADC Channel 0
62 AREF Reference Voltage
63 GND Ground
64 AVCC Voltage Supply Pin for ADC

3. ATmega128 Main Functions

ATmega128 can perform a number of functions on a single chip. Large memory space with more number of pins interface put this device ahead of other controllers available in the AVR community. Following are the major functions associated to this tiny module.
Timer
Atmega128 comes with four timers i.e. two 8-bit and two 16-bit timers. These timers play a vital role in creating a delay of any running functions and can be used both ways i.e. timers as well as counters where former is used to control the internal functions of the controller and increments the instruction cycle, while later counts the number of intervals by incrementing the rising and falling edge of the pin and is mainly used for external functions. Two other timers added in the device are
  • Oscillator Start-up Timers
  • Power Up Timer
Oscillator start-up timer resets the controller to stabilize the crystal oscillator. And power-up timer is used to generating a minor delay once you power on the device, helps in stabilizing the power signals.
Number of Sleep Modes
This device incorporates Six Sleeping Modes for power saving purpose. These modes include:
  • Power-save
  • Power-down
  • Idle
  • ADC Noise Reduction
  • Standby
  • Extended Standby
Brown Out Detect (BOD)
The BOD, also known as BOR (Brown Out Reset), is a valuable addition to the device that helps in resetting the module once the Vcc (voltage supply) goes below a brownout threshold voltage. In this mode, multiple voltage ranges are produced to save the module once the power drops at the voltage supply line. If you aim to bring back the device from BOD function, it is advised to enable the Power Up Timer for creating a slight delay.
Watchdog Timer
Most of the chips, if not all, produced by Microchip, incorporate a built-in watchdog timer that resets the controller if the running program hangs up during compilation or gets stuck in the infinite loop. The main purpose of this timer is to prevent the controller from resetting it manually, giving you a slight edge over other processors where you need to wrestle your mind to manually reset the controller in case there comes a glitch in the running function. The watchdog timer behaves like a countdown timer.
Interrupt
The interrupts are very helpful for calling the desired function that puts the main running function on hold until the required instruction is executed. The controller goes back to the main program once the interrupt is executed.
I2C Communication
I2C protocol is used to layout the communication between low-speed devices like ADC and DAC converters and microcontrollers. It is a two wire communication that mainly contains two lines
  • Serial Clock (SCL)
  • Serial Data (SDA)
The former is a clock signal, mainly used to synchronize the data transfer between the devices and is generated by the master device, while the later is used to hold the desired data.
SPI Communication
ATmega128 houses a serial peripheral interface (SPI) that is mainly used for communication between the microcontroller and other peripheral devices such as sensors, shift registers, and SD cards. Separate clock and data lines are available, layered with a select line for selecting the relevant device for communication. Two pins used for SPI communication are as follow
  • MOSI (Master Output Slave Input)
  • MISO (Master Input Slave Output)
The MOSI pin is used for receiving the data when the microcontroller acts as a slave. Similarly, MISO helps in sending data by the microcontroller while later acts as a slave mode.

4. ATmega128 Compilers

Compilers are the basic software used for writing and compiling the code into the AVR controller. Some are free to use and some are paid. If you are getting your hands-on very first time with the controllers, it is advised to go with the free version, you can move to paid version as you grow and learn with the passage of time. Following are some basic compilers mainly used for AVR microcontrollers.
  • The IAR is a paid compiler and comes with a professional interface. As per the testimonials and personal experience of some of the experts, this compiler proves to the best version for the AVR microcontrollers.
  • CodeVision houses a CodeWizard and turns out to be highly economical for the controllers.
  • The GCC Port is another good pick to start with, but it comes with a bit complex interface. It works with both Windows and Linux operating systems.
  • ImageCraft is a valuable addition for compiling the code, but it doesn't incorporate some GUI features like editor and project management that may put you in big trouble during the code execution.

5. ATmega128 Memory Interface

Two memory types are mainly used in ATmeag128 named as Program Memory (Flash Memory) and SRAM memory where former makes use of a single pipelining for the execution of the instructions and later is a volatile memory mainly depends on the power supply source.  This AVR module incorporates a Harvard Architecture where separate memories spaces are reserved for both data and program. The memory space in the controller is nothing but a combination of the linear and regular memory maps. The Fast Access File Register is layered with 32 x 8 – Bit general purpose working registers. The single clock cycle is enough for accessing these registers and laying out the ALU (Arithmetic Logic Unit) operation where the result is stored in the Register file.
Program Memory (ROM)
Program memory has a memory space around 128K where recent instruction is called followed by the next instruction, executing the instructions in every clock cycle.
  • It is mainly categorized into two parts named as the Boot Program section and Application Program section. The former comes with Applications Flash Memory that plays the main part for SPM instruction writing.
Data Memory (RAM)
The data memory has a memory space around 4K. Five different addressing modes in the AVR architecture are used for addressing this RAM memory. These modes are named as
  • Direct
  • Indirect
  • Indirect with Displacement
  • Indirect with Pre-decrement
  • Indirect with Post-increment.
Three address registers, known as X, Y, and Z, increment and decrement in indirect addressing modes. Control registers are present in the flexible interrupt module that mainly come with global interrupt enable bit laying in the Status Register. These interrupts come with an Interrupt Vector Table where Interrupt Vector is a major part of it and both are inversely proportional to each other. It is important to note that, the Interrupt Vector table depends on the Interrupt Vector Position.
  • The ALU module operates in a single clock cycle and is divided into three main functions called direct, arithmetic and bit functions, that are directly connected with 32 general purpose registers.

6. ATmega128 Block Diagram

Following figure shows the block diagram of ATmega128.
  • ATmega128 comes with six software selectable power saving modes. The Power-down is very helpful for freezing the Oscillator and stops all other module functions while keeping the register contents saved. The functions remain disabled until the next interrupt is called and executed.
  • Similarly, the Idle mode allows the interrupt system, SPI Port, SRAM, Timers/Counter to function while keeping the CPU disabled.
  • The ADC Noise Reduction mode plays a vital role in minimizing the switching noise and freezes entire module except asynchronous ADC and Timers.
  • In the Power-save mode, the entire device is sleeping except asynchronous timer which continues to run.
  • The Standby mode puts the whole device in sleep mode except Crystal Oscialltor which continues to run, helping to consume low power. The Extended Standby mode allows both the Oscillator and the Asynchronous Timer to run while the rest of the device sleeps.
ATmega128 Applications
  • Embedded systems
  • Industrial Automation
  • Students Projects
  • Making of quadcopters
  • Home automation
That's all for today. I hope I have given you everything you needed to know about ATmega128. If you are unsure or have any question, you can approach me in the comment section below. I'll try and help you according to the best of my knowledge. Feel free to keep us updated with your valuable suggestions, so we keep providing quality work and you keep visiting us every now and then. Thanks for reading the article.

Introduction to ATmega8

Hi Friends! Hope you are doing well. I am back to give you a daily dose of useful information so you can excel and improve as per your technical needs and requirements. Today, I'll uncover the details on the Introduction to ATmega8. It is an 8-bit AVR microcontroller that is based on RISC CMOS technology and comes with a 28-pin interface for the PDIP package. The Program memory is 8K Flash while RAM and EEPROM are 1K and 512 bytes respectively.

Microchip has been the main source for producing PIC and AVR microcontrollers that are mainly used in embedded and industrial automation systems. These modules can perform a number of functions on a tiny chip, preventing you from spending too much and purchasing external components for laying out automation in the relevant project.

In this post, I’ll cover each and everything related to this tiny chip including main features, pinout, pin description, functions, the compiler used and everything you need to know. Let’s get down to the details of this onboard module:

Introduction to ATmega8

  • ATmega8 is a 28-pin, 8-bit AVR microcontroller, based on RISC architecture, designed by Microchip and is mainly used in the embedded systems and industrial automation projects.
  • It comes in three packages known as PDIP, MLF, and TQFP, where the first one contains 28 pins and the other two come with 32-pin on each module.
  • The Program memory(Flash Memory) is 8KB used to store the programming code and permanent settings.
  • Atmega8 comes with a RAM memory of 1KB, it's a volatile memory and refreshes on restart.
  • It also has an EEPROM memory of 512 bytes, which is a semi-volatile memory.
  • Other features includes are a power-up timer, a watchdog timer, Brown out Detection, In-Circuit Serial Programming and five sleep modes.
  • The instruction set is the main criteria that set this module apart from the PIC microcontroller where the former executes most instructions in one clock cycle and comes with 32 general-purpose registers while later requires a number of clock cycles per instruction and comes with W register.
  • The 10-bit ADC module is added to the device that plays a vital role for sensor interfacing and contains a total of 6 channels for the PDIP package and 8 channels for the remaining two packages.
  • Communication protocols like SPI, I2C, and USART are added to the device that is widely used for establishing communication with external devices.

ATmega8 Key Features

  • Before you start working on the relevant project, it is advised to check the features of the module, in order to get an idea if these features are suitable for the project you aim to work on.
  • The following table shows the main features of ATmega8.
Atmega8 Key Features
No. of Pins 28
CPU 8-Bit AVR
Operating Voltage 2.7 to 5.5 V
Program Memory 8K
Program Memory Type Flash
RAM 1K Bytes
EEPROM 512 Bytes
ADC Number of ADC Channels 10-Bit 6 in PDIP, 8 in TQFP and QFN
Comparator 1
PWM Channels 3
Oscillator up to 16 MHz
Timer (3) 16-Bit Timer (1) 8-Bit Timer (2)
Packages (3) PDIP (28-Pins) TQFP (32-Pins) QFN (32)
Power Up Timer Yes
I/O Pins 23
Manufacturer Microchip
SPI Yes
I2C Yes
Watchdog Timer Yes
Brownout Detection (BOD) Yes
USART Yes
Sleep Modes 5
Minimum Operating Temperature -55 C
Maximum Operating Temperature 125 C

ATmega8 Pinout and Description

  • You have got a brief introduction to the module. In this section, we will cover the pinout and description of each pin.

Pinout

  • The following figure shows the pinout of ATmega8.
  • ATmega8 comes in three packages known as PDIP, MLF, and TQFP where the first is used for prototype projects, while the other two are used for industrial and electronic devices.
  • The following table shows the complete description of each pinout, which will help you anticipate the major function associated with each pin.
Atmega8 pinout & Description
1 PC6 RESET PCINT14 I/O Pin RESET will be generated by keeping this pin LOW for longer than the minimum pulse length Interrupt
2 PD0 RXD PCINT16 I/O Pin Serial Receive Pin (USART) Interrupt
3 PD1 TXD PCINT17 I/O Pin Serial Transmit Pin (USART)Interrupt
4 PD2 INT0 PCINT18 I/O Pin External Interrupt Interrupt
5 PD3 INT1 OC2B PCINT19 I/O Pin External Interrupt Dedicated Pin for Timer (PWM Channel) Interrupt
6 PD4 T0 XCK PCINT20 I/O Pin T0 ( Timer0 External Counter Input) XCK ( USART External Clock I/O) Interrupt
7 VCC Voltage Supply
8 GND Ground Pin
9 PB6 OSC1 XTAL1 PCINT6 I/O Pin Oscillator Input Pin Interrupt
10 PB7 OSC2 XTAL2 PCINT7 I/O Pin Oscillator Output Pin Interrupt
11 PD5 T1 OC0B PCINT21 I/O Pin PinT1 ( Timer0 External Counter Input) Dedicated Pin for Timer (PWM Channel) Interrupt
12 PD6 AIN0 OC0A PCINT22 I/O PinAnalog Comparator Positive Dedicated Pin for Timer (PWM Channel) Interrupt
13 PD7 AIN1 PCINT23 I/O Pin Analog Comparator Negative Interrupt
14 PB0 ICP1 CLKO PCINT0 I/O Pin In Circuit Serial Programming Clock Interrupt
15 PB1 OC1A PCINT1 I/O Pin Dedicated Pin for Timer (PWM Channel) Interrupt
16 PB2 SS OC1B PCINT2 I/O Pin SPI Slave Select Input. When the controller acts as a slave, this pin is LOW Dedicated Pin for Timer (PWM Channel) Interrupt
17 PB3 MOSI OC2A PCINT3 I/O Pin MOSI (Master Output Slave Input) for SPI Communication. The data is received by this pin when the controller acts as a slave Dedicated Pin for Timer Interrupt
18 PB4 MISO PCINT4 I/O Pin MISO (Master Input Slave Output) for SPI communication. When the controller acts as a slave, the data is sent by a controller to master through this pin Interrupt
19 PB5 SCK PCINT5 I/O Pin SCK (SPI Bus Serial Clock). This clock is shared between the controller and other devices for data transfer Interrupt
20 AVCC Voltage Supply Pin for ADC
21 AREF Voltage Reference
22 GND Ground Pin
23 PC0 ADC0 PCINT8 I/O Pin Analog Channel 0 Interrupt
24 PC1 ADC1 PCINT9 I/O Pin Analog Channel 1 Interrupt
25 PC2 ADC2 PCINT10 I/O Pin Analog Channel 2 Interrupt
26 PC3 ADC3 PCINT11 I/O Pin Analog Channel 3 Interrupt
27 PC4 ADC4 SDA PCINT12 I/O Pin Analog Channel 4 Serial Data (I2C) Interrupt
28 PC5 ADC5 SCL PCINT13 I/O Pin Analog Channel 5 Serial Clock (I2C) Interrupt

ATmega8 Main Functions

  • ATmega8 comes with the ability to execute and perform a number of functions.
  • Following are the major functions related to this tiny module.

Timer

Atmega8 incorporates three timers where two are 8-bit and one is a 16-bit timer.  These timers can be used both ways i.e. timer as well as a counter where the former is used to create the delay in any running function, controls the internal functions of the controller and increments the instruction cycle, while later is used to count the number of intervals by incrementing the rising and falling edge of the pin and is mainly used for external functions. Apart from these timers, two other timers are included in the device named as

  • Oscillator Start-up Timers
  • Power Up Timer

An oscillator start-up timer is used to make the crystal oscillator stable by resetting the controller. And power-up timer generates a minor delay once you power on the device, helping in stabilizing the power in order to generate power signals with continuous intervals.

Number of Sleep Modes

Five Sleep Modes are incorporated into the device that helps in saving power. These modes include:

  • Power-save
  • Power-down
  • Idle
  • ADC Noise Reduction
  • Standby

Brown Out Detect (BOD)

The BOD, also known as BOR (Brown Out Reset), is used to resetting the module once the Vcc (voltage supply) goes below a brownout threshold voltage. It is important to note that, the Power Up Timer must be enabled for creating a delay and helping in bringing back the device from a BOD function. In this mode, multiple voltage ranges are created to protect the module once the power drops at the voltage supply line.

SPI Communication

ATmega8 comes with a serial peripheral interface (SPI) - A communication module that helps in establishing communication between the microcontroller and other peripheral devices such as shift registers, SD cards, and sensors. It incorporates a separate clock and data lines with the addition of a select line for selecting the relevant device for communication.

Two pins used for SPI communication are as follow:

  • MOSI (Master Output Slave Input)
  • MISO (Master Input Slave Output)

The MOSI pin receives the data when the controller acts as a slave. And MISO plays a vital role in sending data by the controller while later is put in the slave mode.

Watchdog Timer

ATmega8 incorporates a built-in watchdog timer that resets the controller if the running program hangs up during compilation or gets stuck in the infinite loop. The watchdog timer is nothing but a countdown timer.

Interrupt

The interrupt hints at a call of emergency that puts the main function on hold until the required instruction is executed. The controller goes to the main program once the interrupt is called and executed.

I2C Communication

  • I2C protocol is used to connect low-speed devices like ADC and DAC converters, and microcontrollers.
  • It is a two-wire communication that comes with:
    • Serial Clock (SCL)
    • Serial Data (SDA)

The former is a clock signal that synchronizes the data transfer between the devices and is produced by the master device, while the latter is used to carry the required data.

ATmega8 Memory Interface

The memory space in the controller is the manifestation of the linear and regular memory map. This AVR module comes with a Harvard Architecture that houses separate memories for both data and program.

  • Single pipelining is used for the executions of the instructions in the Program Memory - A programmable Flash Memory - where the next instruction is called and executed followed by the next instruction that helps in executing the instructions in every clock cycle.

The Fast Access File Register comes with 32 x 8 - Bit general purpose working registers that can be accessed with the single clock cycle that assists in performing the ALU (Arithmetic Logic Unit) operation where the result is stored in the Register File.

The I/O Memory can be accessed in multiple ways by direct manner or using data Space locations covering Register File, 0x20 – 0x5F.

Program Memory (ROM)

  • Program memory comes with a memory space around 8K and can perform the instructions in every clock cycle.
  • It stores information permanently and doesn't depend on the source of power supply and is widely known as ROM or Non-Volatile Memory.
  • The program memory address can access 16 or 32-bit instruction.
  • Program Flash is divided into two parts including the Application Program section and the Boot Program section.
  • The latter comes with Applications Flash Memory used for SPM instruction writing.

Data Memory (RAM)

The data memory comes with memory space around 1K (1024 bytes). It can be accessed through the five different addressing modes in the AVR architecture named Direct, Indirect, Indirect with Displacement, Indirect with Pre-decrement, and Indirect with Post-increment.

  • Three address registers X, Y, and Z are capable to increment and decrement with regular intervals in the presence of indirect addressing modes.

The flexible interrupt module houses control registers that further contain global interrupt enable bit sitting in the Status Register. All these interrupts contain Interrupt Vector Table with Interrupt Vector where the former depends on the Interrupt Vector Position and are inversely proportional to each other.

  • The ALU module, which is divided into three major functions known as direct, arithmetic and bit functions, has a direct connection with 32 general-purpose registers within a single clock cycle.

ATmega8 Compilers

If you are new to a microcontroller, you may be a little skeptical about the compiler you can use for writing and compiling the code into your AVR controller. I've combined some of the basic compilers where some are better than others in terms of efficiency. Although the free versions may lack some features, they are recommended to start with as a newbie to get hands-on experience with the AVR controller.

  • The IAR compiler proves to be the best compiler for AVR. Although it is expensive and incorporates a highly professional interface.
  • The GCC Port is a good option for AVR that works with both Linux and Windows. The interface is a little bit complex.
  • ImageCraft is another right option to start with, but it lacks some GUI features like editor and project management that may create trouble during the execution of code.
  • CodeVision comes with CodeWizard and is highly economical.

6. ATmega8 Interfacing with Arduino

ATmega8 can be interfaced with Arduino for the development of the embedded project. The following figure shows the interfacing of ATmega8 with Arduino.
  • If you are new to the Arduino Board, you must try these Arduino Projects for Beginners, they will help understand the major functions of the Arduino Board.

ATmega8 Internal Block Diagram

  • A Block diagram will help you get a hold of how major functions and components are connected and perform inside the device.
  • The following figure shows the block diagram of ATmega8:
  • ATmega8 is a low-power CMOS AVR microcontroller that is mainly based on RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8 is capable to perform and execute powerful instructions using 1MIPS per MHz in a single clock cycle that drastically helps in optimizing the power consumption.

8. ATmega8 Projects and Applications

  • Used in embedded and robotics system
  • It is widely used in students projects
  • Home Security System
  • For the designing of quadcopters
  • Industrial Automation
That's all for today. I hope you have found this article information. If you are unsure or have any questions, you can approach me in the comment section below. I'd love to help you the best way I can. Feel free to feed us with your valuable suggestions - they help us provide you quality work. Thanks for reading the article.

Introduction to ATmega168

Hi Friends! Hope you are doing well. We always strive to give you valuable information as per your needs and requirements so you keep coming back for what we have to offer. Today, I'll uncover the details on the Introduction to ATmega168. It is an 8-bit AVR microcontroller that comes with 32-pin interface and is mainly based on RISC CMOS technology. The Program memory is 16K, based on Flash, and incorporates read-write capabilities. The module comes with a wide temperature range from -40 to 85 ºC while operating voltage ranges from 1.8 to 5.5 V. If you are working on project that is related to automation and embedded systems, you can not write off the importance of this module that comes with an ability of performing a number of functions at once on a single chip. In this post, I'll cover each and everything related to this module including main features, pinout, pin description, functions, the compiler used and real-time applications. Let's jump right it, and get down to the nitty-gritty of this little toy.

Introduction to ATmega168

  • ATmega168 is an 8-bit AVR microcontroller that comes in three packages named as PDIP, MLF, and TQFP, where the first two contain 28 pins on each module while other comes with 32-pin interface.
  • The Program memory is 16K that is based on Flash while other two memories RAM and EEPROM contain 1K and 512 Bytes respectively with data retention capability of around 20 years.
  • The 10-bit ADC module is added in the device that plays a vital role for sensor interfacing and contains total 8 channels that are enough to provide analog to digital conversion to a number of pins.
  • Only a few controllers incorporate all three communication protocols i.e. SPI, I2C and USART and ATmega168 is one of them. These protocols are widely used for setting up a communication with external devices.
  • Apart from providing decent pace for executing a number of instructions, other features this module includes a watchdog timer, power up timer, oscillator start-up timer, Brown out Detection and In-Circuit Serial Programming.
  • What Makes this AVR module Different from PIC Microcontrollers is the instruction set. PIC microcontrollers require a number of clock cycles per instruction while AVR executes most instructions in one clock cycle. Also, PIC contains a 'W' register, while AVR comes with 32 general purpose registers where three pairs can be employed as pointers.

1. ATmega168 Features

Features of any device are very important to get a hold of major functions and characteristics associated with it. Following table shows the main features of this module.
ATmega168 Features
No. of Pins 28
CPU RISC 8-Bit CMOS
Operating Voltage 1.8 to 5.5 V
Program Memory 16K
Program Memory Type Flash
RAM 1K
EEPROM 512 Bytes
ADC Number of ADC Channels 10-Bit 8
Comparator 1
In-circuit serial programming Yes
Oscillator up to 20 MHz
Timer (3) 16-Bit Timer (1) 8-Bit Timer (2)
Capture/Compare/PWM 1/1/6
Power Up Timer Yes
I/O Pins 23
USART Yes
SPI 2
I2C Yes
Watchdog Timer Yes
Brown out Detection (BOD) Yes
Power on Reset Yes
Data Retention 20 Years
Minimum Operating Temperature -40 ºC
Maximum Operating Temperature 85 ºC

2. ATmega168 Pinout and Description

In this section, we will cover the pinout and pin description of each pin of the controller so you can anticipate the main functions associated with the pins. The following figure shows the pinout of ATmega168.
  • ATmega168 comes in three packages named as PDIP, MLF, and TQFP where first is used for the development of individual projects while the other two are added to the industrial and electronic devices.
Pin Description
Following table shows the pin description of each pin that will help you foresee the major functions associated with each pin of the controller.
Pin# Pin Name Pin Description
1 PC6 RESET PCINT14 Digital I/O Pin RESET will be generated by keeping this pin LOW for longer than the minimum pulse length Interrupt
2 PD0 RXD PCINT16 Digital I/O Pin Serial Receive Pin (USART) Interrupt
3 PD1 TXD PCINT17 Digital I/O Pin Serial Transmit Pin (USART) Interrupt
4 PD2 INT0 PCINT18 Digital I/O Pin External Interrupt Interrupt
5 PD3 INT1 OC2B PCINT19 Digital I/O Pin External Interrupt Dedicated Pin for Timer (PWM Channel) Interrupt
6 PD4 T0 XCK PCINT20 Digital I/O Pin T0 ( Timer0 External Counter Input) XCK ( USART External Clock I/O) Interrupt
7 VCC Voltage Supply
8 GND Ground Pin
9 PB6 OSC1 XTAL1 PCINT6 Digital I/O Pin Oscillator Input Pin Interrupt
10 PB7 OSC2 XTAL2 PCINT7 Digital I/O Pin Oscillator Output Pin Interrupt  
11 PD5 T1 OC0B PCINT21 Digital I/O Pin T1 ( Timer0 External Counter Input) Dedicated Pin for Timer (PWM Channel) Interrupt  
12 PD6 AIN0 OC0A PCINT22 Digital I/O Pin Analog Comparator Positive Dedicated Pin for Timer (PWM Channel) Interrupt    
13 PD7 AIN1 PCINT23 Digital I/O Pin Analog Comparator Negative Interrupt
14 PB0 ICP1 CLKO PCINT0 Digital I/O Pin In Circuit Serial Programming Clock Interrupt
15 PB1 OC1A PCINT1 Digital I/O Pin Dedicated Pin for Timer (PWM Channel) Interrupt
16 PB2 SS OC1B PCINT2 Digital I/O Pin SPI Slave Select Input. When the controller acts as a slave, this pin is LOW Dedicated Pin for Timer (PWM Channel) Interrupt
17 PB3 MOSI OC2A PCINT3 Digital I/O Pin MOSI (Master Output Slave Input) for SPI Communication. The data is received by this pin when the controller acts as a slave Dedicated Pin for Timer Interrupt
18 PB4 MISO PCINT4 Digital I/O Pin MISO (Master Input Slave Output) for SPI communication. When the controller acts as a slave, the data is sent by a controller to master through this pin Interrupt
19 PB5 SCK PCINT5 Digital I/O Pin SCK (SPI Bus Serial Clock). This clock is shared between the controller and other devices for data transfer Interrupt
20 AVCC Voltage Supply Pin for ADC
21 AREF Voltage Reference
22 GND Ground Pin
23 PC0 ADC0 PCINT8 Digital I/O Pin Analog Channel 0 Interrupt
24 PC1 ADC1 PCINT9 Digital I/O Pin Analog Channel 1 Interrupt
25 PC2 ADC2 PCINT10 Digital I/O Pin Analog Channel 2 Interrupt
26 PC3 ADC3 PCINT11 Digital I/O Pin Analog Channel 3 Interrupt
27 PC4 ADC4 SDA PCINT12 Digital I/O Pin Analog Channel 4 Serial Data (I2C) Interrupt
28 PC5 ADC5 SCL PCINT13 Digital I/O Pin Analog Channel 5 Serial Clock (I2C) Interrupt

3. ATmega168 Main Functions

ATmega168 comes with an ability to execute and perform a number of functions. Following are the major functions related to this tiny module.
Timer
Atmega168 comes with three timers where two are 8-bit and one a 16-bit timer.  These timers can be used as a timer as well as a counter. The timer mode is used to create the dealy in any running function that increments the instruction cycle and mainly controls the internal functions of the controller. While the counter mode counts the number of intervals in any function and is mainly used for external functions where it can increment the rising and falling edge of the pin.
  • Oscillator Start-up Timers
  • Power Up Timer
Oscillator start-up timer resets the controller until the crystal oscillator becomes stable. Similarly, power-up timer is added that generates a minor delay once you power on the device, that provides an appropriate time to stabilize the power where it can generate power signals in a continuous manner.
Brown Out Detect (BOD)
The BOD, also known as BOR (Brown Out Reset), is a very valuable function that resets the module once the Vcc (voltage supply) goes below a brownout threshold voltage. In this mode, multiple voltage ranges are used and generated to protect the module once the power drops at the voltage supply line, setting you free from manually resetting the device. The Power Up Timer must be enabled, that creates the delay in bringing back the device from a BOD function.
Number of Sleep Modes
Six Sleep Modes are added to the device that help in saving power. These modes include:
  • Idle
  • ADC Noise Reduction
  • Power-save
  • Power-down
  • Standby
  • Extended Standby
SPI Communication
ATmega168 incorporates a serial peripheral interface (SPI) that nails down a communication between the microcontroller and other peripheral devices such as SD cards, shift registers, and sensors. It comes with separate clock and data lines with the addition of a select line to select the given device for communication. Two pins called used for SPI communication are as follow MOSI (Master Output Slave Input) MISO (Master Input Slave Output) The data is received by MOSI pin when the controller acts as a slave. And MISO is responsible for sending data by the controller when later acts as a slave.
Interrupt
The interrupt is used for a call of emergency which puts the main function on hold and executes the required instructions essential at that time. Once the interrupt is called and executed the running instruction brings the controller back to the main program.
I2C Communication
I2C protocol is a two-wire protocol used to connect low-speed devices like ADC and DAC converters, and microcontrollers. It comes with two wires called Serial Clock (SCL) Serial Data (SDA)  The former behaves like a clock signal that is produced by the master device and synchronizes the data transfer between the devices. And the later is used to carry the desired data.
Watchdog Timer
ATmega168 comes with a built-in watchdog timer that brings the controller back in reset position if the program hangs up during compilation or gets stuck in the infinite loop. The watchdog timer acts like a countdown timer in the running function.

4. ATmega168 Memory Interface

This AVR controller encompasses the Harvard Architecture that provides separate memory locations for both Data and Program memory. The memory is based on Atmel’s high-density technology where Program Memory, also known as Flash memory, can be reprogrammed through SPI serial interface using two ways i.e. Non-volatile memory programmer or On-chip boot code. The CPU is very useful to access memories and perform calculations on the basis of the number of instructions fed into the controller.
Program Memory (ROM)
Program memory performs the instructions in every clock cycle at regular intervals. It is also known as ROM or non-volatile memory that stores the information permanently and works perfectly in the absence of power supply.
  • The controller program memory executes the required instruction followed by the next instruction. Every program memory address is able to access a 16- or 32-bit instruction.
Program memory comes with a memory space around 16K - lot more than some other controllers available in the AVR community.
  • Program Flash is mainly categorized into two sections i.e. Application Program section and the Boot Program section. Lock bits are reserved for read/write protection. The Boot Program Section houses Application Flash Memory that is responsible for SPM instruction writing.
Data Memory (RAM)
The data memory contains 1K (1024 bytes) memory space. It categorizes the memory locations three ways where first 32 locations access the file register, next 64 locations are allocated for standard I/O memory and remaining are employed for internal data SRAM. The data memory is categorized into five addressing modes known as
  • Direct,
  • Indirect
  • Indirect with Displacement
  • Indirect with Pre-decrement
  • Indirect with Post-increment
The memory space in the controller shows the linear and regular memory map. The address registers X, Y, and Z can increment and decrement with regular intervals when indirect addressing modes are coupled with both pre-decrement and post-increment. It is important to note that, the I/O Memory can be accessed in two ways i.e. using data Space locations covering Register File, 0x20 - 0x5F or in a direct manner.

5. ATmega168 Compilers

Compilers are used for writing and compiling the code in the AVR microcontroller. Following are some compilers you can use for this AVR module.
  • The IAR is the best compiler for AVR. It is expensive and incorporates highly professional interface. If you are a beginner, it is advised to use this compiler as per your technical needs and requirements.
  • CodeVision is cheap and easy to use that incorporates CodeWizard.
  • The GCC Port is another compiler for AVR. It is available FREE for both Linux and Windows operating systems. It comes with little bit complex interface that may put you in trouble right off the bat.
  • ImageCraft is a valuable option but it lacks some GUI features where editor and project management are quite formidable and can create trouble for the code execution.

6. ATmega168 Interfacing with Arduino

ATmega168 can be interfaced with Arduino to drive automation in the relevant project. Both modules work perfectly in embedded systems where they can perform a number of useful functions. The following figure shows the pinout how Arduino pins are connected with ATmega168.
  • If you aim to work on this Arduino board then you must try these Arduino Projects for Beginners, they will help to get familiar with the Arduino Board.

7. ATmega168 Block Diagram

If you intend to closely look into the device and how major functions and components are connected and performed inside the device, a block diagram will help you out. The following figure shows the block diagram of ATmega168.
  • AVCC is a voltage supply for analog to digital converter that is necessary to power up the ADC module. Power on reset and brown out detect house in the same package that is also connected with the watchdog timer.

8. ATmega168 Projects and Applications

  • It is widely used in students projects
  • Used in embedded and robotics system
  • Industrial Automation
  • Home Security System
  • For the designing of quadcopters
That's all for today. I hope you have found this article useful. If you are feeling skeptical or have any question, you can approach me in the comment section below. I'd love to help you in any way I can according to the best of my expertise. Feel free to keep us updated with your valuable suggestion, they help us provide you quality work as per your needs and demands. Thanks for reading the article.

Introduction to ATtiny85

Hey Guys! Hope you are doing well. I am back to give you a daily dose of valuable information. Today, I'll discuss the details on the Introduction to ATtiny85. It is an 8-bit AVR microcontroller, introduced by Microchip, and is based on RISC CPU. It comes with 8-pin interface (PDIP) and falls under the category of low power controllers. Programmable watchdog timer and 10-bit ADC converter are added in the device that makes it suitable for sensor interfacing and resetting the device in case it gets stuck in an infinite loop. Microchip never fails to satisfy the requirements of any individual by providing flawless microcontroller modules that are directly or remotely connected with automation and embedded systems. With the invention of these tiny onboard modules, development of electronic projects has become easy and hassle-free more than ever before. In this tutorial, I'll cover each and everything related to ATtiny85, its pinout, pin description, main features, block diagram, and applications. Let get down to the nitty-gritty of this module and nail down everything you need to know.

Introduction to ATtiny85

  • ATtiny85 is an 8-bit AVR microcontroller that comes with 8-pin interface and mainly used in automation and Arduino projects.
  • The CPU is based on RISC architecture and is mainly called low power controller that stands fit for the real-time applications that can operate on minimum power.
  • The program memory is 8KB while both EEPROM and RAM contain a memory space of around 512 bytes. These memory spaces are very useful for storing the number of instruction in the form of code.
  • This module comes with only one port called Port B that is a bi-directional port and contains 6 I/O pins with internal pull-up resistors. The output buffers on PORTB are designed with symmetrical drive characteristics that come with both high sink and source capability. It is important to note that, Port B pins are externally pulled low and tri-stated that will source current if the pull-up resistors are activated.
  • External and internal interrupts are available on the board, while 32 general purpose registers are included in the device that are mainly called data holding spaces.
  • Two 8-bit timers are added in the device where one timer comes with compare modes and can be used both ways i.e. timer as well as a counter while other is high-speed timer/counter.
  • This module comes with software select power saving modes that are very helpful for the applications that operate with minimum power.
  • Like other controllers introduced by the Microchip, this module comes with 10-bit ADC converter that houses 4 analog channels that help in sensor interfacing and converting analog signals to digital ones.
  • This tiny chip is available in four packages called PDIP, SOIC, TSSOP, and QFN where first three come with 8-pin interface while the last one contains 20 pins.
  • Digital communications like I2C and SPI can be easily employed using this module that helps in developing a communication with external devices.

1. ATtiny85 Features

You have got a brief overview of this module. Now we cover the main features that will help you anticipate the major characteristic associated with the module. The following figure shows the complete features of ATtiny85.
ATtiny85 Features
No. of Pins 8
CPU RISC 8-Bit AVR
Operating Voltage 1.8 to 5.5 V
Program Memory 8K
Program Memory Type Flash
RAM 512 Bytes
EEPROM 512 Bytes
ADC Number of ADC Channels 10-Bit 4
Comparator 1
Packages PDIP (8-Pin) SOIC (8-Pin) TSSOP (8-Pin) QFN/MLF (20-Pin)
Oscillator up to 20 MHz
Timer (2) 8-Bit Timers
Enhanced Power on Reset Yes
Power Up Timer Yes
I/O Pins 6
Manufacturer Microchip
SPI Yes
I2C Yes
Watchdog Timer Yes
Brown out detect (BOD) Yes
Reset Yes
USI (Universal Serial Interface) Yes
Minimum Operating Temperature -40 C
Maximum Operating Temperature 125 C
  • You must check these features before making a final decision to install and use this module for your relevant project.

2. ATtin85 Pinout and Description

Until now, you have got a hold of basic information and complete features of ATtiny85. In this section, we will discuss the pinout and pin description of the module.
Pinout
Following figure shows the pinout of ATtiny85.
  • The bottom pad available on the board must be soldered to the ground.
  • The DNC marked on the pinout stands for don't connect.
Pin Description
Following table shows the pin description that will help you understand the major functions associated with each pin.
Pin# Pin Name Pin Description
1 PB5 PCINT5 RESET ADC0 dW I/O Bidirectional pin Interrupt Reset Analog Channel 0 Define Word
2 PB3 PCINT3 XTAL1 CLKI OC1B ADC3 I/O Bidirectional pin Interrupt Crystal Oscillator Pin 1 Clock Analog Channel 3
3 PB4 PCINT4 XTAL2 CLKO OC1B ADC2   I/O Bidirectional pin Interrupt Crystal Oscillator Pin 2 Clock Analog Channel 2  
5 PB0 MOSI DI SDA AIN0 OC0A OC1A AREF PCINT0 I/O Bidirectional pin SPI Serial Data (I2C) Analog Input Compare Register Voltage Reference Interrupt  
6 PB1 MISO DO AIN1 OC0B OC1A PCINT1 I/O Bidirectional pin SPI Serial Data (I2C) Analog Input Compare Register Interrupt
7 PB2 SCK USCK SCL ADC1 T0 PCINT2 I/O Bidirectional pin Serial Clock Line (I2C) Analog Channel 1 Timer 0 Interrupt
4 GND Ground Pin
8 Vcc Voltage Supply Pin

3. ATtiny85 Main Functions

ATtiny85 can perform a number of functions on a single chip. Some pins come with an ability to employ more than one functions. Following are the main functions of this module.
Timers
There are two timers included on the chip that help in generating a delay in the running process of certain function when they work in a timer mode. In the counter mode, these timers are used to count the number of the interval on a specific function inside in the controller. The timer mode increments the instruction cycle while the counter mode is used to increment the rising and falling edge of the pin.
SPI Communication
ATtiny85 comes with a serial peripheral interface (SPI) that is mainly used for communication between the microcontroller and other peripheral devices such as SD cards, sensors, and shift registers. It incorporates separate clock and data lines with the addition of a select line to pick the required device for communication. This communication allows both connected device to lay out the same path of communication under one communication protocol.
I2C Communication
I2C protocol is added in the device that is mainly two-wire protocol used to connect low-speed devices like ADC and DAC converters, I/O interfaces and microcontrollers. The two wires, known as Serial Clock (SCL) and Serial Data (SDA), are the main part of this communication protocol. The SCL line behaves like a clock signal that is generated by the master device and synchronizes the data transfer between the devices. While the SDA line is used to carry the required data.
Brown Out Reset (BOD)
The BOD is a very useful function that helps in resetting the controller once the Vdd (voltage supply) drops below a brownout threshold voltage. The multiple voltage ranges are provided to secure the module once the power drops at the voltage supply line.
 Interrupt
The interrupt plays a vital role in an emergency which puts the main function on hold and executes the required instructions that are necessary at that time. Once the interrupt is executed the running code puts the controller back to the main program.
ADC Converter
ADC module is a valuable addition in the device that makes it compatible with the sensors. It is a 10-bit module that contains 4 channels which are little less than the number of channels available on the modules introduced by Microchip that, more or less, come with 7 or 12 channels.

4. ATtiny85 Memory Interface

The memory of this little toy is designed and based on Atmel's high-density technology that is basically non-volatile in nature. The Program Memory can be reprogrammed through SPI serial interface using two ways i.e. On-chip boot code or non-volatile memory programmer. The main program execution is mainly done inside CPU that plays a vital role to access memories and perform calculations on the basis of the number of instructions incorporated into the controller. This module falls under the category of AVR controllers that are based on Harvard architecture and come with separate locations reserved for both program and data memory.
Program Memory (ROM)
Program memory, that is basically reprogrammable flash memory, works in a simple manner where next instruction stands in the queue once first is called and executed. This helps in executing the instructions with regular intervals in every clock cycle. The Flash memory comes with 8k memory space and contains memory endurance around 10,000 write/erase cycle (means you can erase and write the instructions 10,000 times on this board). The program counter available on the flash memory is 12bits wide that can address 4096 program memory locations.
Data Memory (RAM)
The data memory comes with 512bytes memory space and reserves the memory locations three ways i.e. first 32 locations access the file register, next 64 locations are reserved for standard I/O memory and remaining are used for internal data SRAM. The data memory is categorized into five addressing modes named as
  • Direct,
  • Indirect
  • Indirect with Displacement
  • Indirect with Pre-decrement
  • Indirect with Post-increment
In the Register File, the registers ranging from R26 to R31 refer to the pointer registers with indirect addressing. While the direct addressing covers the entire data space. Similarly, the Indirect with Displacement mode covers 63 address locations using base address accessed by the Y- or Z register. The address registers X, Y, and Z increment and decrement with regular intervals when indirect addressing modes are layered with both post-increment and pre-decrement.
EEPROM Data Memory
This memory comes with 512 bytes of memory space which is designed and laid out as a separate data space where single bytes can be accessed. It comes with a memory endurance around 100,000 write/erase cycles which is ten times more than program memory.

5. ATtiny85 Compilers

There are many compilers available for compiling the code in the AVR microcontroller. Some are better than others. Before you pick some compiler for your controller, make sure it is easy to use and stand fit for your needs and requirements.
  • If you are in the learning phase, then IAR is the best compiler for AVR. It is highly professional, though expensive, what it lacks in economical price, it covers up by providing both flawless quality and ease of use where it can support most, if not all, of the MCU families.
Another compiler for AVR is the GCC Port for AVR that is available FREE for both Windows and Linux. It can compile the instructions with a decent pace, however, if you are a newbie and getting your hands on very first time with the controller, it might be hard to learn.
  • ImageCraft is good option to start with that has made a decent place in the market but lack of GUI features make this compiler difficult to handle where editor and project management are quite daunting and can put you in a total stall in the start.
CodeVision is another easiest compiler that comes with CodeWizard and helps in starting a new project sooner than later. Also, it is highly economical.

6. ATtiny85 Block Diagram

Block diagram is very helpful to visualize the main function available inside the controllers and how each feature and component are connected with each other. Following figure shows the block diagram of ATtiny85.
  • The AVR core is used to combine 32 general purpose register with the rich instruction set.
  • Also, these 32 registers are directly connected with the ALU (Arithmetic Logic Unit) which helps in accessing the two independent registers using single instruction.

7. Interfacing ATtiny85 with Arduino

Tiny things can work wonders if used a proper way. Both ATtiny85 and Arduino, when connected, can easily drive automation in your project and help in executing the number of instructions. You can connect ATtiny85 with the Arduino following way.
  • Arduino Pin 10 ...................... ATtiny85 Pin 1
  • Arduino Pin 11 ...................... ATtiny85 Pin 5
  • Arduino Pin 12 ...................... ATtiny85 Pin 6
  • Arduino Pin 13 ...................... ATtiny85 Pin 7
  • Arduino +5V...................... ATtiny85 Pin 8
  • Arduino Ground ...................... ATtiny85 Pin 4

8. Applications

  • It is mainly used in real time applications related to industrial automation.
  • Embedded Systems Projects make use of this module to drive automation.
  • It can be employed and incorporated in robotics.
  • Aeronautical technology houses a wide range of AVR controllers covering Quad-copter and space Aeroplanes.
  • Power monitoring and management systems use this module.
That's all for today. I hope you have found this piece of nugget useful and valuable as per your technical needs and demands. If you are unsure or have any question, you can ask me in the comment section below. I'd love to help you according to the best of my knowledge and skills. Feel free to keep us updated with your valuable feedback and suggestions, so we keep providing quality work and you keep coming back for what we have to offer. Thanks for reading the article.

Introduction to Arduino Mega 2560

Hey Fellas! Hope you are doing well. Today, I am going to unlock the details on the Introduction to Arduino Mega 2560. It is a microcontroller board based on Atmega 2560 microcontroller. Arduino Boards have revitalized the automation industry with their easy-to-use platform where everyone with little or no technical background can get started with learning some basic skills to program and run the board.

I have updated articles previously on Arduino Uno, Arduino Nano, and Arduino Pro Mini. All these boards function similarly in one way or the other. There are some basic features like PCB layout design, size, number of analog pins and breadboard friendly nature that make them different from each other. In terms of coding, all these boards are programmed in Arduino IDE software and you don't need to attach extra components or devices to put them in running condition. Everything is already built in the board that makes this device readily available. Just plug and play with the board as per your requirement. Here's the video presentation of Arduino Mega 2560:

All the boards mentioned above work perfectly for a number of Arduino Projects when you require a simple task to be completed with fewer I/O pins and memory. However, when the project goes complex, a board with less memory fails to complete the task. This is where Arduino Mega 2560 comes in handy. This board comes with 54 pins and 16 analog pins with more memory to store the code. Sounds crazy, isn't it? Thanks to technology that keep your covered in every aspect and provides support in any way when it comes to fulfilling your technical needs.

I'll try to cover each and everything related to Arduino Mega 2560, what is this about, the main features, working, technical specifications and everything you need to know. Let's jump right in.

No. Pin Number Pin Description
1 D0 - D53 54 Digital Input / Output Pins.
2 A0 - A15 16 Analog Input / Output Pins.
3 D2 - D13 12 Pulse Width Modulation ( PWM ) Pins.
4 Pin # 0 (RX) , Pin # 1 (TX) Pin # 19 (RX1) , Pin # 18 (TX1) Pin # 17 (RX2) , Pin # 16 (TX2) Pin # 15 (RX3) , Pin # 14 (TX3)  4 Serial Communication Ports (8 Pins).
5 Pin # 50 ( MISO ) Pin # 51 ( MOSI ) Pin # 52 ( SCK ) Pin # 53 ( SS ) SPI Communication Pins.
6 Pin # 20 ( SDA ), Pin # 21 ( SCL ) I2C Communication Pins.
7 Pin # 13 Built-In LED for Testing.
Other Arduino Boards:
You should also have a look at these other Arduino board, you might find them interesting as well. Compare their features and find the most suitable one for your project. Here's the list of other Arduino boards:
Where To Buy?
No.ComponentsDistributorLink To Buy
1Arduino Mega 2560AmazonBuy Now

Introduction to Arduino Mega 2560

  • Arduino Mega 2560 is a Microcontroller board based on Atmega2560. It comes with more memory space and I/O pins as compared to other boards available in the market.
  • There are 54 digital I/O pins and 16 analog pins incorporated on the board that make this device unique and stand out from others.
  • Out of 54 digital I/O, 15 are used for PWM (pulse width modulation).
  • A crystal oscillator of 16MHz frequency is added on the board.
  • This board comes with USB cable port that is used to connect and transfer code from computer to the board.
  • DC power jack is coupled with the board that is used to power the board. Some version of the Arduino board lacks this feature like Arduino Pro Mini doesn't come with DC power jack.
  • ICSP header is a remarkable addition to Arduino Mega which is used for programming the Arduino and uploading the code from the computer.
  • You can download the Arduino Mega 2560 datasheet bu clicking below button:
Download Arduino Mega 2560 Datasheet
  • This board comes with two voltage regulator i.e. 5V and 3.3V which provides the flexibility to regulate the voltage as per requirements as compared to Arduino Pro Mini which comes with only one voltage regulator.
  • There is no much difference between Arduino Uno and Arduino Mega except later comes with more memory space, bigger size and more I/O pins.
  • Arduino software called Arduino IDE is used to program the board which is a common software used for all boards belonged to Arduino family.
  • Availability of Atmega16 on the board makes it different than Arduino Pro Mini which uses USB to serial converter to program the board.
  • There is a reset button and 4 hardware serial port called USART which produces a maximum speed for setting up communication.
  • The following figure shows the specifications of Arduino mega 2560.
  • Arduino Mega is specially designed for the projects requiring complex circuitry and more memory space. Most of the electronic projects can be done pretty well by other boards available in the market which make Arduino Mega uncommon for regular projects. However, there are some projects that are solely done by Arduino Mega like making of 3D printers or controlling more than one motors, because of its ability to store more instructions in the code memory and a number of I/O digital and analog pins.
  • There are three ways to power the board. You can either use a USB cable to power the board and transfer code to the board or you can power it up using Vin of the board or through Power jack or batter.
  • Last two sources to power the board are required once you already built and compile code into the board through USB cable.
  • This board comes with resettable polyfuse that prevents the USB port of your computer from overheating in the presence of high current flowing through the board. Most of the computers come with an ability to protect themselves from such devices, however, the addition of fuse provides an extra layer of protection.
  • It can be used either way i.e. for creating stand-alone projects or in combination with other Arduino boards. Most complex projects can be created using this board.
Let's have a look at Arduino Mega 2560 Pinout:

Arduino Mega 2560 Pinout

  • Following figure shows the pinout of Arduino Mega 2560:
  • Each pin comes with a specific function associated with it. All analog pins can be used as digital I/O pins.
  • Designing of a project using Arduino Mega gives you the flexibility of working with more memory space and processing power that allows you to work with a number of sensors at once. This board is physically larger than other Arduino boards.

Arduino Mega 2560 Pin Description

  • 5V & 3.3V. This pin is used to provide output regulated voltage around 5V. This regulated power supply powers up the controller and other components on the board. It can be obtained from Vin of the board or USB cable or another regulated 5V voltage supply. While another voltage regulation is provided by 3.3V pin. Maximum power it can draw is 50mA.
  • GND. There are 5 ground pins available on the board which makes it useful when more than one ground pins are required for the project.
  • Reset. This pin is used to reset the board. Setting this pin to LOW will reset the board.
  • Vin. It 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.
  • Serial Communication. RXD and TXD are the serial pins used to transmit and receive serial data i.e. Rx represents the transmission of data while Tx used to receive data. There are four combinations of these serial pins are used where Serail 0 contains RX(0) and TX(1), Serial 1 contains TX(18) and RX(19), Serial 2 contains TX(16) and RX(17), and Serial 3 contains TX(14) and RX(15).
  • External Interrupts. Six pins are used for creating external interrupts i.e interrupt 0(0), interrupt 1(3), interrupt 2(21), interrupt 3(20), interrupt 4(19), interrupt 5(18). These pins produce interrupts by a number of ways i.e. providing LOW value, rising or falling edge or changing value to the interrupt pins.
  • 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. This gives you the change of nursing your programming skills in real time.
  • AREF. AREF stands for Analog Reference Voltage which is a reference voltage for analog inputs.
  • Analog Pins. There are 16 analog pins incorporated on the board labeled as A0 to A15. It is important to note that all these analog pins can be used as digital I/O pins. Each analog pin comes with 10-bit resolution. These pins can measure from ground to 5V. However, the upper value can be changed using AREF and analogReference() function.
  • I2C. Two pins 20 and 21 support I2C communication where 20 represents SDA (Serial Data Line mainly used for holding the data) and 21 represents SCL(Serial Clock Line mainly used for providing data synchronization between the devices)
  • SPI Communication. SPI stands for Serial Peripheral Interface used for the transmission of data between the controller and other peripherals components. Four pins i.e. 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS) are used for SPI communication.

Arduino Mega 2560 Dimensions

Follwoing figure shows the dimensions of the Arduino Mega 2560:
  • Arduino Mega is comparatively larger than other boards available in the market. It comes 4-inch length and 2.1-inch width. However, USB port and power jack are slightly extended from the given dimensions.

Shield Compatibility with Arduino Mega 2560

  • Arduino Mega is compatible with most of the shields designed for other Arduino boards.
  • Before you intend to use a shield, make sure the operating voltage of the shield is compatible with the board voltage. Most of the shields operate at 3.3V or 5V which is compatible with this board, however, shields with higher operating voltage can damage the board.
  • Also, the header distribution of the shield must resonate with the pin distribution of the board, so you can simply attach the shield with the board and make it in a running condition.

Arduino Mega 2560 Programming

  • Arduino Mega 2560 can be programmed using Arduino Software called IDE which supports C programming.
  • The code you make on the software is called sketch which is burned in the software and then transferred to the board through USB cable.
  • This board comes with a built-in bootloader which rules out the usage of an external burner for burning the code into the board.
  • The bootloader communicates using STK500 protocol.
  • Once you compile and burn the program on the board, you can unplug the USB cable which eventually removes the power from the board. When you intend to incorporate the board into your project, you can power it up using power jack or Vin of the board.
  • Multitasking is another feature where Arduino mega comes handy. However, Arduino IDE Software doesn't support multitasking feature but you can use other operating systems like FreeRTOS and RTX to write C program for this purpose. This gives you the flexibility of using your own custom build program using ISP connector.

Arduino Mega 2560 Applications

Arduino Mega 2560 is an ideal choice for the projects requiring more memory space to used with more number of number pins on the board. Following are the main applications of the Arduino mega boards.
  • Developing 3D printer
  • Controlling and handling more than one motors
  • Interfacing of number of sensors
  • Sensing and detecting temperature
  • Water level detection projects
  • Home automation and security systems
  • Embedded Systems
  • IoT applications
  • Parallel programming and Multitasking
That's all for today. I hope you have found this article useful. However, if you are unsure or have any question you can ask me in the comment section below. I'd love to help you according to best of my expertise. Feel free to keep us updated with your feedback and suggestions, they help us provide you quality work that resonates with your field of work and helps you keep coming back for what we have to offer. Thanks for reading the article.
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir