Introduction :-
In this project we use ATmega16 controller and a 16x2 alphanumeric LCD. Program is loaded in the ATmega16 and the digital calender is ready to run. This calender is starts from 2013 and ends in 2100. You can reduce delay for seeing results quickly.
Lcd Interfacing :-
see.. LCD INTERFACING WITH ATmega16 IN 4-BIT MODE
ATmega16 :-
In 4-bit mode ground the first 4 data pins of LCD means pin 7-11. make the connections as shown above.
In this project we use ATmega16 controller and a 16x2 alphanumeric LCD. Program is loaded in the ATmega16 and the digital calender is ready to run. This calender is starts from 2013 and ends in 2100. You can reduce delay for seeing results quickly.
Lcd Interfacing :-
see.. LCD INTERFACING WITH ATmega16 IN 4-BIT MODE
ATmega16 :-
Components required :-
- 10k ohm registance
- 10k ohm variable registance
- 8 MHZ crystal oscilltor
- 16x2 LCD
- ATmega16 IC
- 12v battery
- Toggle button
- 7805 IC
- 330 ohm resistance
- 1N4007 diode
- 1000uf capacitor
- Green LED
Circuit Diagram :-
In 4-bit mode ground the first 4 data pins of LCD means pin 7-11. make the connections as shown above.
Code (compiled in CVAVR) :-
(see.. CVAVR TUTORIAL (CODE VISION AVR))
Note :- In CVAVR program window delete all the lines and paste the code given below. because there are so much unnecessary lines.
-----------------------------------------------------------------------------------------------------------------------
#include <mega16.h>
#include <delay.h>
#include <stdlib.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>
void main(void)
{
int i=0,y,m,d,k=0;
char c[20];
// LCD module initialization
lcd_init(16);
lcd_gotoxy(2,0);
lcd_putchar('/');
lcd_gotoxy(5,0);
lcd_putchar('/');
while (1)
{
for(y=2013;y<2100;y++)
{
lcd_gotoxy(6,0);
itoa(y,c);
lcd_puts(c);
for(m=1;m<=12;m++)
{
if(m<=9)
{
lcd_gotoxy(3,0);
itoa(i,c);
lcd_puts(c);
itoa(m,c);
lcd_gotoxy(4,0);
lcd_puts(c);
}
else
{
itoa(m,c);
lcd_gotoxy(3,0);
lcd_puts(c);
}
if(m<=7&&m%2==1)
{
for(d=1;d<=31;d++)
{
k++;
lcd_gotoxy(0,1);
if(k==1)
lcd_putsf("TUESDAY ");
if(k==2)
lcd_putsf("WEDNESDAY");
if(k==3)
lcd_putsf("THRUSDAY ");
if(k==4)
lcd_putsf("FRIDAY ");
if(k==5)
lcd_putsf("SATURDAY ");
if(k==6)
lcd_putsf("SUNDAY ");
if(k==7)
{
lcd_putsf("MONDAY ");
k=0;
}
if(d<=9)
{
lcd_gotoxy(0,0);
itoa(i,c);
lcd_puts(c);
itoa(d,c);
lcd_gotoxy(1,0);
lcd_puts(c);
delay_ms(1000);
}
else
{
itoa(d,c);
lcd_gotoxy(0,0);
lcd_puts(c);
delay_ms(1000);
}
}
}
else if(m>=8&&m%2==0)
{
for(d=1;d<=31;d++)
{
k++;
lcd_gotoxy(0,1);
if(k==1)
lcd_putsf("TUESDAY ");
if(k==2)
lcd_putsf("WEDNESDAY");
if(k==3)
lcd_putsf("THRUSDAY ");
if(k==4)
lcd_putsf("FRIDAY ");
if(k==5)
lcd_putsf("SATURDAY ");
if(k==6)
lcd_putsf("SUNDAY ");
if(k==7)
{
lcd_putsf("MONDAY ");
k=0;
}
if(d<=9)
{
lcd_gotoxy(0,0);
itoa(i,c);
lcd_puts(c);
itoa(d,c);
lcd_gotoxy(1,0);
lcd_puts(c);
delay_ms(1000);
}
else
{
itoa(d,c);
lcd_gotoxy(0,0);
lcd_puts(c);
delay_ms(1000);
}
}
}
else if(m==2&&y%4==0)
{
for(d=1;d<=29;d++)
{
k++;
lcd_gotoxy(0,1);
if(k==1)
lcd_putsf("TUESDAY ");
if(k==2)
lcd_putsf("WEDNESDAY");
if(k==3)
lcd_putsf("THRUSDAY ");
if(k==4)
lcd_putsf("FRIDAY ");
if(k==5)
lcd_putsf("SATURDAY ");
if(k==6)
lcd_putsf("SUNDAY ");
if(k==7)
{
lcd_putsf("MONDAY ");
k=0;
}
if(d<=9)
{
lcd_gotoxy(0,0);
itoa(i,c);
lcd_puts(c);
itoa(d,c);
lcd_gotoxy(1,0);
lcd_puts(c);
delay_ms(1000);
}
else
{
itoa(d,c);
lcd_gotoxy(0,0);
lcd_puts(c);
delay_ms(1000);
}
}
}
else if(m==2&&y%4!=0)
{
for(d=1;d<29;d++)
{
k++;
lcd_gotoxy(0,1);
if(k==1)
lcd_putsf("TUESDAY ");
if(k==2)
lcd_putsf("WEDNESDAY");
if(k==3)
lcd_putsf("THRUSDAY ");
if(k==4)
lcd_putsf("FRIDAY ");
if(k==5)
lcd_putsf("SATURDAY ");
if(k==6)
lcd_putsf("SUNDAY ");
if(k==7)
{
lcd_putsf("MONDAY ");
k=0;
}
if(d<=9)
{
lcd_gotoxy(0,0);
itoa(i,c);
lcd_puts(c);
itoa(d,c);
lcd_gotoxy(1,0);
lcd_puts(c);
delay_ms(1000);
}
else
{
itoa(d,c);
lcd_gotoxy(0,0);
lcd_puts(c);
delay_ms(1000);
}
}
}
else
{
for(d=1;d<=30;d++)
{
k++;
lcd_gotoxy(0,1);
if(k==1)
lcd_putsf("TUESDAY ");
if(k==2)
lcd_putsf("WEDNESDAY");
if(k==3)
lcd_putsf("THRUSDAY ");
if(k==4)
lcd_putsf("FRIDAY ");
if(k==5)
lcd_putsf("SATURDAY ");
if(k==6)
lcd_putsf("SUNDAY ");
if(k==7)
{
lcd_putsf("MONDAY ");
k=0;
}
if(d<=9)
{
lcd_gotoxy(0,0);
itoa(i,c);
lcd_puts(c);
itoa(d,c);
lcd_gotoxy(1,0);
lcd_puts(c);
delay_ms(1000);
}
else
{
itoa(d,c);
lcd_gotoxy(0,0);
lcd_puts(c);
delay_ms(1000);
}
}
}
}
}
}
}
-----------------------------------------------------------------------------------------------------------------------
Proteus simulation:-