Introduction to Arduino Mega 2560 | Pinout | Features | Proteus Simulation

The Engineering Projects
20 Jun 202118:47

Summary

TLDRIn this tutorial, the host provides a comprehensive guide to the Arduino Mega 2560, covering its theoretical aspects, hardware architecture, pin configurations, and communication protocols. The video also demonstrates how to simulate the board using Proteus software. The host walks through interfacing an LCD and keypad with the Arduino Mega, including a step-by-step code demonstration to display keypad inputs on the LCD. The video concludes with practical troubleshooting tips, helping viewers successfully design and simulate their own Arduino projects in Proteus.

Takeaways

  • šŸ˜€ The video provides a comprehensive tutorial on the Arduino Mega 2560, explaining its theory and a practical simulation using Proteus software.
  • šŸ“Š The tutorial is divided into four parts: introduction to Arduino Mega, hardware architecture, adding the library to Proteus, and designing a simulation.
  • šŸ”Œ Arduino Mega 2560 has 54 digital pins for interfacing digital sensors and modules, and 16 analog pins for analog sensors.
  • šŸ“ The board includes 15 PWM pins for controlling devices like DC motors and has 7 ground pins distributed across the board.
  • šŸ”‹ Arduino Mega can be powered through a USB port or a 12V DC adapter, and has a reset pin and button for restarting.
  • šŸ’¾ The board has three types of built-in memory: 256 KB Flash (non-volatile), 8 KB SRAM (volatile), and 4 KB EEPROM (semi-volatile).
  • šŸ“” Arduino Mega supports three communication protocols: Serial, SPI, and I2C, allowing connection to modules like GSM or RTC.
  • šŸ“ The board includes four hardware serial ports, enabling the connection of up to four serial modules simultaneously.
  • āš™ļø The video demonstrates how to interface both an LCD and a 4x4 keypad with the Arduino Mega, using Proteus to simulate and display pressed keypad characters on the LCD.
  • šŸ’” The tutorial recommends using Proteus for simulation and programming testing before working with real hardware, as it's time-efficient and cost-effective.

Q & A

  • What is the main focus of the tutorial in the provided transcript?

    -The tutorial focuses on a detailed overview of the Arduino Mega 2560, including its theory, hardware architecture, and simulation in Proteus software.

  • How is the tutorial structured?

    -The tutorial is divided into four parts: an introduction to Arduino Mega 2560, its hardware architecture, adding its library to Proteus, and designing a small simulation with LCD and keypad.

  • What is the purpose of the Arduino Mega 2560?

    -The Arduino Mega 2560 is a microcontroller board designed for interfacing with digital sensors, modules, and analog sensors, featuring more memory space and I/O pins compared to other Arduino boards.

  • How many digital and analog pins does the Arduino Mega 2560 have?

    -The Arduino Mega 2560 has 54 digital pins (0 to 53) and 16 analog pins (A0 to A15).

  • What are the functions of the PWM pins on the Arduino Mega 2560?

    -The PWM pins on the Arduino Mega 2560 are used to generate PWM signals for controlling the speed of devices like DC motors.

  • What are the three power pins on the Arduino Mega 2560 and their functions?

    -The three power pins on the Arduino Mega 2560 are Vin for input voltage, 5V for providing power, and 3.3V for lower voltage requirements.

  • What is the role of the Reset Pin on the Arduino Mega 2560?

    -The Reset Pin on the Arduino Mega 2560 is used for resetting the board programmatically by making it LOW.

  • How can you add the Arduino Mega library to Proteus software?

    -You can add the Arduino Mega library to Proteus by downloading the library files and placing them in the library folder of your Proteus software.

  • What is the purpose of the variable resistor (pot dash HG) in the LCD circuit?

    -The variable resistor in the LCD circuit controls the brightness of the LCD display.

  • How many communication protocols does the Arduino Mega support, and what are they?

    -The Arduino Mega supports three communication protocols: Serial Protocol, SPI Protocol, and I2C Protocol.

  • What is the significance of the bootloader in the Arduino Mega 2560?

    -The bootloader is a pre-installed software code in the flash memory of the Arduino Mega 2560 that facilitates the uploading of user programs to the board.

Outlines

00:00

šŸ˜€ Introduction and Overview of Arduino Mega 2560

The speaker welcomes viewers and introduces the topic of Arduino Mega 2560. The tutorial is divided into four parts: basic introduction, hardware architecture, adding its library to Proteus software, and a practical simulation project involving LCD and keypad interfacing with the Arduino Mega. The speaker emphasizes the importance of understanding the theory before moving to practical implementation.

05:02

šŸ”§ Hardware Architecture and Pin Functions

This section dives into the hardware architecture of Arduino Mega 2560, covering its 54 digital pins and 16 analog pins. It explains how to configure these pins for input/output and their additional functionalities, including PWM for controlling motors. The board's power and ground pins are discussed, as well as its reset button, ICSP header, and 16MHz crystal oscillator. Various power options for the board are explained, including USB and DC power jack.

10:03

šŸ’” Memory Types and Communication Protocols

The speaker explains Arduino Mega's communication protocols: Serial, SPI, and I2C, discussing their respective pins and usages. Additionally, the memory architecture of Arduino Mega is broken down into three types: Flash memory (256 KB, for storing permanent code and settings), SRAM (8 KB, for storing temporary data), and EEPROM (4 KB, for semi-permanent data storage). The bootloader's role in using up 8 KB of the Flash memory is highlighted.

15:08

šŸ›  Practical Simulation in Proteus

The speaker explains the practical side of the tutorial, focusing on simulating Arduino Mega 2560 in Proteus software. Viewers are encouraged to use simulations to practice programming instead of working directly with hardware. Instructions are given on how to download and install Arduino Mega libraries for Proteus and how to start a simulation, interfacing components like LCD and keypad.

šŸ“ŗ Simulation Setup and Code Compilation

This part explains how to set up and connect components in the Proteus workspace, including LCD, keypad, and variable resistor. The Arduino IDE is used to compile code and generate the necessary hex file for simulation. The speaker addresses common errors, such as forgetting to connect a ground to the read/write pin of the LCD, and demonstrates troubleshooting and fixing issues in real-time.

šŸ”¢ Keypad and LCD Integration with Arduino Mega

The tutorial continues with the integration of a 4x4 keypad and an LCD, explaining how to set up the keypad pins and modify code to display keypad inputs on the LCD. The speaker discusses the importance of correctly assigning pin labels and using the Arduino keypad and LCD libraries. A common issue with printing characters in the same location is resolved by moving the set cursor code.

šŸ“š Final Code Adjustments and Simulation

The speaker explains the final adjustments to the code, focusing on ensuring that the keypad characters print correctly on the LCD screen by properly setting the cursor position. The simulation is rerun to verify everything is working. The tutorial concludes with a message to the viewers, encouraging them to visit the blog for more details and ask any questions in the video comments.

Mindmap

Keywords

šŸ’”Arduino Mega 2560

Arduino Mega 2560 is a microcontroller board designed by Arduino.cc, featuring an ATmega2560 microcontroller. It is known for having more memory space and input/output pins compared to other Arduino boards, making it suitable for more complex projects. In the video, the Arduino Mega 2560 is the central device around which the tutorial is built, with discussions on its hardware architecture, pin functions, and its use in simulations.

šŸ’”Proteus Software

Proteus Software is a tool used for simulating electronic circuits and is mentioned in the script as the platform where the Arduino Mega 2560 will be virtually demonstrated. The video will guide viewers on how to add the Arduino library to Proteus for designing simulations, which is a practical way to learn and test Arduino programming without the need for physical components.

šŸ’”Pinout

Pinout refers to the arrangement of pins on a microcontroller and their functions. In the context of the video, the Arduino Mega 2560's pinout is discussed, which includes 54 digital pins and 16 analog pins, each with specific roles such as input, output, PWM signals, and communication protocols. Understanding pinout is crucial for interfacing sensors and modules with the Arduino board.

šŸ’”PWM (Pulse Width Modulation)

PWM is a technique used to encode a message into a pulsing signal, which is particularly useful for controlling the speed of motors. In the video, it is mentioned that the Arduino Mega has 15 PWM pins that can be used to generate PWM signals, which is important for applications like motor control where variable speed is required.

šŸ’”Ground Pins

Ground pins are essential in electronic circuits as they provide a common reference point for electrical potential. The video script mentions that the Arduino Mega has 7 ground pins distributed across the board, which are used to connect the ground of various components to ensure proper circuit operation.

šŸ’”Power Pins

Power pins on the Arduino Mega 2560, as discussed in the script, include Vin, 5V, and 3.3V. These pins are used to supply power to the board and connected components. Understanding the power requirements and how to connect power sources is fundamental for operating the board and ensuring the stability of the circuit.

šŸ’”Reset Pin

The Reset Pin on the Arduino Mega 2560 is used to reset the board programmatically, which is a common feature in microcontrollers for troubleshooting and restarting operations. In the video, it is mentioned that making this pin LOW will reset the board, which is a simple way to recover from programming errors or system crashes.

šŸ’”ICSP Header

ICSP stands for In-Circuit Serial Programming and the ICSP header on the Arduino Mega is used for connecting third-party modules that require programming or communication through the SPI interface. The video script briefly touches on this feature, indicating the board's expandability and versatility.

šŸ’”Crystal Oscillator

A crystal oscillator provides a stable clock signal for the microcontroller, ensuring accurate timing and synchronization. The Arduino Mega 2560 features a 16MHz crystal oscillator, as mentioned in the script, which is a critical component for the reliable operation of the board and its programs.

šŸ’”Communication Protocols

Communication protocols such as Serial, SPI, and I2C are essential for data transfer between the Arduino Mega and other modules. The video discusses these protocols, explaining how they are used for interfacing with various sensors and modules like GSM and RTC, which are integral for creating interactive and responsive projects.

šŸ’”EEPROM Memory

EEPROM, or Electrically Erasable Programmable Read-Only Memory, is a type of non-volatile memory used for storing data that must persist even when power is lost. The video script explains that the Arduino Mega has 4KB of EEPROM memory, which is used for storing settings and data that do not need to be changed frequently.

Highlights

Introduction to Arduino Mega 2560 microcontroller board and its applications.

Explanation of why Arduino Mega 2560 is popular due to its memory and input/output pins.

Overview of Arduino Mega's 54 digital pins and 16 analog pins for interfacing sensors and modules.

Detailing the usage of pins as input or output in programming based on the component being interfaced.

Description of PWM pins (2-13 and 44-46) for generating PWM signals, useful for controlling motor speed.

Explanation of the board's power system, including 7 ground pins, 5V, 3.3V pins, and two main power connectors.

Introduction to the board's communication protocols: Serial, SPI, and I2C, for connecting external modules.

Overview of Arduino Mega's four hardware serial ports, allowing the connection of up to four serial modules.

Explanation of the built-in memory types in Arduino Mega: Flash Memory (256 KB), SRAM (8 KB), and EEPROM (4 KB).

Instructions for setting up the Arduino Mega simulation in Proteus software using custom libraries.

Step-by-step process to install Arduino Mega 2560 library into Proteus and use it for simulations.

Demonstration of interfacing an LCD and a 4x4 keypad with Arduino Mega in Proteus simulation.

Modification of the Arduino IDE code to interface the keypad and display pressed keys on the LCD.

Troubleshooting tips for common issues in simulation, such as adjusting variable resistors for LCD brightness.

Final simulation where pressing buttons on the keypad displays the corresponding characters on the LCD.

Transcripts

play00:26

ļ»æHello friends, I hope you all are doing great.Ā  Welcome to our YouTube Channel ā€œThe EngineeringĀ Ā 

play00:31

Projectsā€. In todayā€™s tutorial, we will haveĀ  a detailed overview of Ardeeno Mega 2560.Ā Ā 

play00:37

We will first discuss the related theory, andĀ  later will simulate it in Proteus software.Ā Ā 

play00:42

So, let's get started! Ā 

play00:47

I have divided this tutorialĀ  into 4 parts. In the first part,Ā Ā 

play00:51

we will discuss the basicĀ  introduction of Ardeeno Mega 2560,Ā Ā 

play00:55

like what is Ardeeno mega, Why we needĀ  to use it, Why is it so famous etc. Ā 

play01:00

In the second part, we willĀ  discuss its hardware architecture,Ā Ā 

play01:03

where we will have a look at its pinout, and theĀ  different functions associated with these pinsĀ Ā 

play01:07

like communication protocols, PWM etc. In the third part, I will show you How toĀ Ā 

play01:13

add its library to Proteus softwareĀ  for designing its simulation.

play01:17

and finally, In the last section, we willĀ  design a small simulation in proteus software.Ā Ā 

play01:22

In the last video, Introduction to Ardeeno UNO, IĀ  have interfaced the UNO board with LCD. So today,Ā Ā 

play01:28

we are going to move one step forward, and willĀ  interface both LCD & keypad with a mega board.Ā Ā 

play01:34

We will design a code that will displayĀ  the pressed key on the LCD screen.

play01:38

I have also shared a complete tutorial on my blogĀ  and its link is given in the description of thisĀ Ā 

play01:43

youtube video.

play01:44

Now, first letā€™s have a look at what is ArduinoĀ Ā 

play01:48

mega 2560? Ardeeno Mega is a microcontrollerĀ  board, designed by Ardeeno dot cc.Ā Ā 

play01:53

The Microcontroller used in thisĀ  Arduino board is At mega 2560.Ā Ā 

play01:58

It comes with more memory space and input outputĀ  pins, as compared to other Ardeeno boards. Ā 

play02:03

Ardeeno mega has 54 digital pins, startingĀ  from 0 to 53. These digital pins are usedĀ Ā 

play02:09

to interface digital sensors and modules withĀ  Arduino mega. Moreover, it has 16 analog pinsĀ Ā 

play02:15

starting from A0 to A15, these pins areĀ  used to interface analog sensors. Ā 

play02:19

We need to specify it in the programming, whetherĀ  we want to use these pins as input or output.Ā Ā 

play02:25

If we are interfacing any sensor, then we need toĀ  make these pins input, so that we could read theĀ Ā 

play02:29

sensorā€™s data but if we want to control any moduleĀ  or motor, then we have to make these pins output,Ā Ā 

play02:34

so that we could send instructions. These pins are also assigned with manyĀ Ā 

play02:36

other functions, for example, we also have 15 PWMĀ  pins in Arduino Mega, which are used to generateĀ Ā 

play02:41

PWM signals. Pin number 2 to 13 are all PWM pinsĀ  and pin number 44, 45 and 46 are also PWM pins.Ā Ā 

play02:51

If you want to control the speed of a DC motor,Ā  then you need to use any of these PWM pins. Ā 

play02:56

It also has 7 Ground pins in total, distributedĀ  over the board. I have encircled them. It also hasĀ Ā 

play03:02

these 3 power pins, Vin will provide the inputĀ  voltage, then we have 5V pin and 3.3V pin. Ā 

play03:08

It also has 1 Reset Pin, which is used forĀ  resetting the board programmatically. MakingĀ Ā 

play03:14

this pin LOW, will reset the board. Thereā€™s alsoĀ  a Reset button present on the mega board. Ā 

play03:19

Moreover, it also has an ICSP header forĀ  connecting third party modules. Ardeeno MegaĀ Ā 

play03:24

comes with a crystal oscillator of 16MHz. In order to power up Arduino mega, we have twoĀ Ā 

play03:29

main power connectors. One is USB PortĀ  and the second one is DC Power Jack.Ā Ā 

play03:35

We can plug a 12V adapter or a battery with thisĀ  power jack, and mega will turn on. Moreover,Ā Ā 

play03:41

if we connect Arduino mega with laptopĀ  via USB port, that will also turn it on.Ā Ā 

play03:46

USB Port is also used to upload code in the megaĀ  board. Ardeeno IDE is the official software usedĀ Ā 

play03:52

for designing and uploading Code. Ā 

play03:54

Moreover, it also has 4 LEDs embedded on it, theĀ  first one is Power LED, it will turn ON as theĀ Ā 

play04:00

mega will be powered up. Second LED is connectedĀ  to Pin number 13 and is used for testing purposes.Ā Ā 

play04:06

When you buy a new Ardeeno mega, then firstĀ  upload the blink code to check this LED.Ā Ā 

play04:11

If it's blinking, your boardā€™s fine,Ā  if not, you need to buy a new one. Ā 

play04:16

Third and fourth LEDs are connected toĀ  TX and RX pins, and they start blinkingĀ Ā 

play04:20

if we perform any serial communication,Ā  which we are going to discuss next.

play04:23

Ardeeno Mega supports 3 typesĀ Ā 

play04:26

of communication protocols, named: SerialĀ  Protocol, SPI Protocol and I2C Protocol.Ā Ā 

play04:32

These communications protocols are used forĀ  data transferring, between mega and third partyĀ Ā 

play04:36

modules. For example, GSM module SIM900 worksĀ  on serial protocol, while RTC module DS 1 3 0 7Ā Ā 

play04:44

works on I2C Protocol, so we need to connect theseĀ  modules with respective pins of Arduino mega. Ā 

play04:50

Ardeeno mega has 4 hardware Serial Ports, whichĀ  means we can connect 4 serial modules withĀ Ā 

play04:55

Ardeeno mega, if you want to connect more thanĀ  4, you need to use software serial library. Ā 

play05:02

Pins of the first serial port are PinĀ  number 0 and 1, where Pin number 0 is RX,Ā Ā 

play05:07

used to receive data, while Pin numberĀ  1 is TX, used to transmit serial data.Ā Ā 

play05:12

The USB Port is internally connected with theseĀ  hardware serial pins, so if you have connectedĀ Ā 

play05:16

any serial module at these pins, you wonā€™t beĀ  able to upload code in Ardeeno mega. So, itā€™sĀ Ā 

play05:22

better to use other serial ports available. Second serial port is available at Pins 18 and 19,Ā Ā 

play05:28

where 18 is TX and 19 is RX. Next we have a serial port at pins 16 and 17,Ā Ā 

play05:33

where Pin number 16 is TXĀ  and pin number 17 is RX. Ā 

play05:37

And the last serial port is at Pin 14Ā  and 15, where pin number 14 is TX andĀ Ā 

play05:42

pin number 15 is RX. ============ Ā 

play05:44

Ardeeno Mega 2 5 6 0 also has 1 SPI Port,Ā  which we can operate through these 4 pins,Ā Ā 

play05:50

Pin number 50, 51, 52 and 53, where Pin numberĀ  50 is M I S O, short for Master In Slave Out, PinĀ Ā 

play05:58

number 51 is M O S I, short for Master Out SlaveĀ  In, Pin number 52 is SCK, short for Serial Clock,Ā Ā 

play06:05

and Pin number 53 is SS, short for Slave Select.Ā  So, using these four digital pins we can performĀ Ā 

play06:12

SPI protocol in Ardeeno mega 2 5 6 0. =========== Ā 

play06:15

The third protocol is I2C protocol, Pins usedĀ  for I2C protocol are 20 and 21. Here, 20 is SDA,Ā Ā 

play06:23

short for Data Line, and 21 is SCL, short forĀ  Clock Line. Again, we have to define it in theĀ Ā 

play06:29

programming, how we want to use these pins. =========== Ā 

play06:36

Now, letā€™s have a look at the builtĀ  in memories present in Ardeeno mega.Ā Ā 

play06:40

Ardeeno mega comes with 3Ā  types of built in memories,Ā Ā 

play06:43

named: Flash Memory, also called ROM, S RAMĀ  Memory, also called RAM, and EEPROM memory Ā 

play06:50

Ardeeno mega 2 5 6 0 has a flash memory ofĀ  256 KB. It's a non volatile memory, meaning,Ā Ā 

play06:58

the data in ROM memory will remain intact, evenĀ  if we remove the power supply of the mega board.Ā Ā 

play07:04

As it's a non volatile memory, thatā€™s why it'sĀ  used for storing the programming code or anyĀ Ā 

play07:08

permanent settings. Bootloader is a software codeĀ  that is pre-installed in every Ardeeno board,Ā Ā 

play07:13

it's installed in the flash memory ofĀ  Ardeeno mega and takes around 8 KB space,Ā Ā 

play07:18

so from 256 KB Flash memory, 8 KB memoryĀ  is already occupied by the bootloader. Ā 

play07:24

Second one is S RAM memory, it'sĀ  short for Static Random Access Memory,Ā Ā 

play07:28

and usually called RAM memory. Ardeeno mega hasĀ  a Ram memory of 8 KB. It's a volatile memory,Ā Ā 

play07:35

so if we reset or restart the mega board,Ā  RAM memory will get erased. This memory isĀ Ā 

play07:40

used to store temporary data like variables. Third type is EEPROM memory, Ardeeno mega hasĀ Ā 

play07:46

an eeprom memory of 4 KB. It's a semi volatileĀ  memory and thus can be erased by programming butĀ Ā 

play07:52

remains intact if power is lost. ====================== Ā 

play07:56

So far, we have studied theoretical knowledgeĀ  about Ardeeno Mega. Now letā€™s practically workĀ Ā 

play08:01

on this powerful board. I am not goingĀ  to work on a real Ardeeno Mega board,Ā Ā 

play08:06

instead I am going to design itsĀ  simulation in Proteus software. Ā 

play08:10

If you want to learn the Ardeeno ProgrammingĀ  language, then I would recommend you to designĀ Ā 

play08:14

simulations in Proteus. Working onĀ  real hardware is quite difficult,Ā Ā 

play08:18

as you have to purchase the components and it alsoĀ  involves electronics. In proteus simulation, youĀ Ā 

play08:23

just have to design your circuit once, and thenĀ  you can completely focus on your programming side.Ā Ā 

play08:28

When I work on Ardeeno projects, I normally designĀ  my programming algorithms in proteus, as testingĀ Ā 

play08:34

with real hardware is too time consuming. Proteus doesnā€™t have Ardeeno boards in itsĀ Ā 

play08:38

components library, but we have designedĀ  its library, which you need to installĀ Ā 

play08:42

in your proteus software, and you will beĀ  able to simulate Ardeeno boards in it. Ā 

play08:46

We have designed two libraries ofĀ  Proteus containing Ardeeno Mega board,Ā Ā 

play08:50

I have given both of these links in theĀ  description of this youtube video. This libraryĀ Ā 

play08:54

is titled as Ardeeno Mega Library for ProteusĀ  version 2 point 0. If you install this library, itĀ Ā 

play09:02

will only add Ardeeno Mega board in your proteusĀ  software. In order to download it, click on thisĀ Ā 

play09:07

download button and it will open this downloadĀ  page, where we need to wait for 20 seconds, Ā 

play09:15

and hereā€™s the link generated, letā€™sĀ  click on this button to download zip file,Ā Ā 

play09:19

and here we got our zip file for Ardeeno megaĀ  2 5 6 0 Proteus Library. I am going to click onĀ Ā 

play09:25

Cancel, as we will install this second library.Ā  This Library is titled Ardeeno library forĀ Ā 

play09:31

proteus version 2 point 0, and by installing thisĀ  library you will get these 6 basic Ardeeno boards.Ā Ā 

play09:37

So, letā€™s install this second one, and againĀ  we need to click on the download button. Ā 

play09:42

Hereā€™s the download page and againĀ  we need to wait for 20 seconds,Ā Ā 

play09:48

letā€™s click on this button to downloadĀ  the zip file of proteus library.Ā Ā 

play09:52

Here, we got our zip file.Ā  Letā€™s click on open with,Ā Ā 

play10:03

open this folder, and here we have this folderĀ  named Proteus Library Files. This zip file alsoĀ Ā 

play10:08

has a simulation ready to simulate, but we willĀ  design a new simulation from scratch in a minute. Ā 

play10:14

First, we need to add these two files inĀ  the library folder of our proteus software,Ā Ā 

play10:18

so extract these files and nowĀ  click on C drive, Program Files,Ā Ā 

play10:22

here we have Lab center electronics,Ā  and then Proteus 7 Professional,Ā Ā 

play10:30

click on library folder and now click ok. As IĀ  already have these files in my library folder,Ā Ā 

play10:36

so I am going to click on Yes to all, thatā€™s it.Ā  We have successfully placed these two files in theĀ Ā 

play10:40

library folder of our proteus software. ================ Ā 

play10:43

================ Now letā€™s open our Proteus software,Ā Ā 

play10:47

and in the components section make aĀ  search for Ardeeno mega. Here selectĀ Ā 

play10:51

Ardeeno mega 2 5 6 0 V 2 point 0, and clickĀ  ok. Letā€™s place Ardeeno mega in the workspace.Ā Ā 

play11:01

So, now we are ready to design its simulation.Ā  In the first tutorial, I have interfaced an LEDĀ Ā 

play11:07

with Ardeeno Nano, and then we have seenĀ  the interfacing of LCD with Ardeeno UNO,Ā Ā 

play11:12

so today we will work on the keypad, we willĀ  interface both LCD and keypad with ArdeenoĀ Ā 

play11:16

Mega. We will press buttons on the keypadĀ  and will display the pressed characters onĀ Ā 

play11:21

20 cross 4 LCD. ============= Ā 

play11:23

So, letā€™s search for few more components,Ā  first I am going to search for LCD Library,Ā Ā 

play11:30

and here we need to select LCD 20 cross 4. Ā 

play11:38

Next, make a search for keypad, I am goingĀ  to select this small calculator keypad.Ā Ā 

play11:43

It's a 4 cross 4 keypad, meansĀ  it has 4 rows and 4 columns. Ā 

play11:48

And, we also need to search for potĀ  dash HG, its a variable resistor.Ā Ā 

play11:52

Select it too. Now, letā€™s click theĀ  OK button to close this dialog box. Ā 

play11:56

================= Letā€™s first place LCD in the workspace,Ā Ā 

play12:01

next we need to connect Terminals,Ā  so clicking on Terminals Mode,Ā Ā 

play12:04

and here we need to select Default. I amĀ  going to quickly place these terminals,Ā Ā 

play12:08

as we have already discussed thisĀ  circuit in the previous video.Ā Ā 

play12:19

Letā€™s add their labels.Ā Ā 

play12:28

Next, we need to connect theseĀ  terminals with the Ardeeno board.Ā Ā 

play12:38

Giving them the same labels as that of LCD pins. ==================== Ā 

play12:48

Now letā€™s open the Ardeeno IDE,Ā Ā 

play12:53

and click on File, and then Examples,Ā  and here we have Liquid Crystal Library,Ā Ā 

play12:57

and I am going to open Hello world example,Ā  letā€™s compile the code to get our hex file.Ā Ā 

play13:09

Hereā€™s our hex file, so I am going toĀ  copy it. Ardeeno IDE creates this hexĀ Ā 

play13:14

file in the temporary folder of the laptop. Now in the proteus simulation, double clickĀ Ā 

play13:19

on Ardeeno mega to open its propertiesĀ  panel. And in the Program File section,Ā Ā 

play13:24

paste the link of the hex file, andĀ  click ok. Now, letā€™s run our simulation.Ā Ā 

play13:32

LCD is not working properly. Ohhh, IĀ  forgot to connect a variable resistor,Ā Ā 

play13:36

letā€™s stop the simulation. ====================== Ā 

play13:38

Letā€™s connect this variable resistor withĀ  the LCD, it controls the brightness of LCD.Ā Ā 

play13:52

Letā€™s run our simulation again, and it's stillĀ  not working. Ohhh, why am I making such sillyĀ Ā 

play13:57

mistakes? We need to connect a Ground with theĀ  read write pin, as we are writing on this LCD.Ā Ā 

play14:03

Letā€™s test it one more time. And yeah, now it'sĀ  working fine. We have a Hello world message,Ā Ā 

play14:09

displayed on LCD. ===================== Ā 

play14:10

Letā€™s stop the simulation to add the keypad.Ā  We need to make some space for the keypad.Ā Ā 

play14:22

Here, I am going to place this 4 cross 4 keypad.Ā Ā 

play14:27

Again, we need to connectĀ  default terminals with its pins.Ā Ā 

play14:46

We need to label these pins, and as I did forĀ  LCD, I am going to use the name of keypad pins. Ā 

play14:59

We also need to connect theseĀ  terminals with the mega board.Ā Ā 

play15:02

So, I am interfacing the keypad with pin numberĀ  14 to 21 of the mega board. Letā€™s assign them theĀ Ā 

play15:08

same labels as that of the keypad. ==================== Ā 

play15:19

Now, letā€™s open the Keypad example. So, File,Ā  Examples, Keypad, and click on Hello keypad.Ā Ā 

play15:30

This example prints pressed keypadĀ  characters on the serial monitor,Ā Ā 

play15:34

letā€™s copy code from it and add it to our LCDĀ  code. First, I am going to copy the Library,Ā Ā 

play15:39

and pasting it here. Letā€™s removeĀ  these comments to clean our code.Ā Ā 

play15:49

Now, letā€™s copy this keypadĀ  initialization code, and paste it here.Ā Ā 

play15:56

We need to make few changes in the code,Ā  to make it compatible with our circuit. Ā 

play16:00

As we are using a 4 cross 4 keypad, so we needĀ  to change the value of columns from 3 to 4.Ā Ā 

play16:11

Next, we need to change theĀ  characters of this array,Ā Ā 

play16:14

and make it look like our keypad in Proteus.Ā Ā 

play16:26

We also need to add theĀ  fourth column in each row. Ā 

play16:35

================ Next, we need to change theĀ Ā 

play16:38

pinout. Keypad rows are attached to pin number 14,Ā  15, 16 and 17, while keypad columns are attachedĀ Ā 

play16:51

to pin number 18, 19, 20 and 21. ================= Ā 

play16:57

We also need to copy paste this keypadĀ  map function. Letā€™s remove these comments.Ā Ā 

play17:14

Hereā€™s the code which will detect the pressedĀ  key of the keypad, and will print it on theĀ Ā 

play17:18

Serial monitor. Letā€™s copy this code, and pasteĀ  it here. As we want to print the keys on LCD,Ā Ā 

play17:24

so letā€™s change this code, its LCD dotĀ  print. Now, we need to compile the code.Ā Ā 

play17:40

And letā€™s run the simulation. Itā€™s working fine.Ā Ā 

play17:43

And you can see, as I am pressing the keypadĀ  button, itā€™s characters are getting printedĀ Ā 

play17:46

on the LCD.. ============ Ā 

play17:48

But these characters are printingĀ  on the same LCD location,Ā Ā 

play17:54

letā€™s stop the simulation. Here, we need to moveĀ  this set cursor code from loop to setup function.Ā Ā 

play18:08

Letā€™s compile the code again.Ā  We need to run the simulation,Ā Ā 

play18:17

and now you can see, keypad charactersĀ  are printing correctly on LCD. Ā 

play18:34

So, that was all for today. I hopeĀ  you have enjoyed todayā€™s tutorial.Ā Ā 

play18:38

I have given all the mentioned links inĀ  the description of this youtube video.Ā Ā 

play18:42

If you have any questions, pleaseĀ  ask in the comments. Take care. Bye.

Rate This
ā˜…
ā˜…
ā˜…
ā˜…
ā˜…

5.0 / 5 (0 votes)

Related Tags
Arduino MegaProteus SimulationMicrocontrollerElectronics TutorialHardware ArchitectureLCD InterfaceKeypad InterfaceProgramming GuideDIY ProjectElectronics Design