Sign In

Keypad Project With Atmega16

iman yashmi iman.yashmi@yahoo.com Iran, Islamic Republic of

Hardware: Keypad & Atmeg16 & Lcd Software: C Project In Atmel Studio6

Hi.
can anyone help me to edit this code
i write this code for keypad to display { '7','8','9','/','4','5','6','*','1','2','3','-', 'C','0','=','+',} in lcd.
but when i simulation in proteus don't work right and just display {'/','*','+','-'}.

Images

keypad project with atmega16

Program

#include <avr/io.h>
#include "lcd.h"
#define F_CPU 1000000UL
#include <util/delay.h>


int main(void)
{
	DDRD=0b00001111;//four neibel upper input,four neibel lower output
	PORTD=0b11110000;
	
	unsigned char shifter[4]={0b11111110,0b11111101,0b11111011,0b11110111};
	unsigned char keypad[16]= { '7','8','9','/',
		                        '4','5','6','*',
					            '1','2','3','-',
					            'C','0','=','+',};
	lcd_init(16);				   
	int row;
	int column=5;
	int position=0;
    while(1)
    {
        for (row=0;row<4;row++)
        {   
	        PORTD=shifter[row];

	          if ((PIND & 0b11101111)==0b11101111)  column=0;
	          if ((PIND & 0b11011111)==0b11011111)  column=1;
	          if ((PIND & 0b10111111)==0b10111111)  column=2;
	          if ((PIND & 0b01111111)==0b01111111)  column=3;
			  
				if (column!=5)
				{
						position=row*4+column;
						lcd_putchar(keypad[position]);
						column=5;
				}

		}
    }
}

Post a reply to iman yashmi

Think you can help iman yashmi ? Then post your thoughts that might help iman yashmi. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.