0% found this document useful (0 votes)
2 views

Keypad Interface

Uploaded by

diyamirani06
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Keypad Interface

Uploaded by

diyamirani06
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Keypad Interface

Code:
#include <avr/io.h>

#include <util/delay.h>

int main()

DDRH = 0xFF;

DDRF = 0xFF;

DDRK = 0x00;
PORTK = 0xFF;

int temp=0;

while (1)

PORTF=temp;

PORTH = ~1;

if((PINK & 0x01)==0x00)

while((PINK & 0x01)==0x00)

temp=7;

_delay_ms(5);

if((PINK & 0x02)==0x00)

while((PINK & 0x02)==0x00);

temp=8;

_delay_ms(5);

if((PINK & 0x04)==0x00)

while((PINK & 0x04)==0x00);

temp=9;

_delay_ms(5);

if((PINK & 0x08)==0x00)

while((PINK & 0x08)==0x00);

_delay_ms(5);

}
PORTH = ~2;

if((PINK & 0x01)==0x00)

while((PINK & 0x01)==0x00);

temp=4;

_delay_ms(5);

if((PINK & 0x02)==0x00)

while((PINK & 0x02)==0x00);

temp=5;

_delay_ms(5);

if((PINK & 0x04)==0x00)

while((PINK & 0x04)==0x00);

temp=6;

_delay_ms(5);

if((PINK & 0x08)==0x00)

while((PINK & 0x08)==0x00);

_delay_ms(5);

PORTH = ~4;
if((PINK & 0x01)==0x00)

while((PINK & 0x01)==0x00);

temp=1;

_delay_ms(5);

if((PINK & 0x02)==0x00)

while((PINK & 0x02)==0x00);

temp=2;

_delay_ms(5);

if((PINK & 0x04)==0x00)

while((PINK & 0x04)==0x00);

temp=3;

_delay_ms(5);

if((PINK & 0x08)==0x00)

while((PINK & 0x08)==0x00);

_delay_ms(5);

PORTH = ~8;

if((PINK & 0x01)==0x00)


{

while((PINK & 0x01)==0x00);

_delay_ms(5);

if((PINK & 0x02)==0x00)

while((PINK & 0x02)==0x00);

temp=0;

_delay_ms(5);

if((PINK & 0x04)==0x00)

while((PINK & 0x04)==0x00);

_delay_ms(5);

if((PINK & 0x08)==0x00)

while((PINK & 0x08)==0x00);

_delay_ms(5);

return 0;

You might also like