Lab 05 - MES
Lab 05 - MES
Lab Manual 05
Session Fall 22
Objectives:
In this lab we will learn:
1. Interfacing of 16x2 LCD & Keypad with ATMEGA Microcontrollers.
Code (Assembly):
#ifndef F_CPU
#define F_CPU 16000000UL // 16 MHz clock speed
#endif
#define D0 eS_PORTD0
#define D1 eS_PORTD1
#define D2 eS_PORTD2
#define D3 eS_PORTD3
#define D4 eS_PORTC1
#define D5 eS_PORTC2
#define D6 eS_PORTC3
#define D7 eS_PORTC4
#define RS eS_PORTC6
#define EN eS_PORTC7
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"
int main(void)
{
DDRD = 0XFF; // Setting the register D for output
DDRC = 0xFF; // Setting the register C for output
char a[8];
Lcd8_Init();
EEAR = 0x5F;
for(int x=0; x<8;x++ )
{
EEDR=i[x];
}
EECR |= (1<<EEMPE);
EECR |= (1<<EEPE);
EECR |= (1<<EERE);
}
return 0;
}
Procedure:
Open proteus on your computer and place down Arduino Mega 2560, one LCD display, keypad,
resistor pack and a ground as shown in the picture.
Copy the hex file from Atmel Software and paste the hex file in the Arduino Mega configuration in
Proteus.
Output (Proteus Simulation):
Code (Assembly):
#define F_CPU 16000000UL
#include "avr/io.h"
#include <util/delay.h>
DDRB=0x80;
unsigned char duty; //set fast PWM mode with non-inverted output
TCCR0A|=(1<<WGM00)|(1<<WGM01)|(1<<COM0A1);
TCCR0B |=(1<<CS00);
while (1)
{
for(duty=0; duty<115; duty++)
{
OCR0A=duty; /*increase the LED light intensity*/
_delay_ms(10);
}
Procedure:
Open proteus on your computer and place down Arduino Mega 2560, one LCD display, keypad,
resistor pack and a ground as shown in the picture.
Copy the hex file from Atmel Software and paste the hex file in the Arduino Mega configuration in
Proteus.
CONCLUSION
In this lab, we have learned how to configure port for input and output in C language and we have also
learned how to interface 16x2 LCD Displays and Keypad with AT mega Microcontrollers. We are given lab
tasks that are implemented on proteus as well as on hardware. Hence, our tasks are completed successfully.