I'm new to AVR,I'm trying this code but its not working,I'm not able to read the keypress,Here there is code for only first row scanning... Pls guide me....
#include#include #include #define ROW1 PINC0 // pin1 #define ROW2 PINC1 // pin2 #define ROW3 PINC2 // pin3 #define ROW4 PINC3 // pin4 #define COL1 PIND0 // pin1 #define COL2 PIND1 // pin2 #define COL3 PIND2 // pin3 #define COL4 PIND3 // pin4 int main(void) { DDRA=0xFF; // Making PORTA as output Port (DATA) DDRB=0x07; // Making PORTB as output (CONTROL) LCD_init(); // LCD Intialization LCD_goto(1,1); // To choose from which line and character the string has to be displayed LCD_print("THE PRESSED KEY:"); // String which has to be displayed on LCD MCUCSR=(1<<JTD); // DISABLING JTAG MCUCSR=(1<<JTD); DDRC=0x00; DDRD=0xFF; PORTC=0x00; //MAKING PORTC AS INPUT PORTD=0xFF; //MAKING PORTD AS OUTPUT PORTD = PORTD & 0x7F; // link column 1 to GND (PORTB0 = 0) asm volatile ("nop"); while(COL1==0) //CHECK IN 1sT COLOUMN { if (ROW1==1) //CHECK IF ANY KEY IN ROW 1 IS PRESSED { LCD_goto(2,7); LCD_print("0"); break; } else if (ROW2==1) //CHECK IF ANY KEY IN ROW 2 IS PRESSED { LCD_goto(2,7); LCD_print("1"); break; } else if (ROW3==1) //CHECK IF ANY KEY IN ROW 3 IS PRESSED { LCD_goto(2,7); LCD_print("2"); break; } else if (ROW4==1) //CHECK IF ANY KEY IN ROW 4 IS PRESSED { LCD_goto(2,7); LCD_print("3"); break; } } }
[capitals removed from thread title and CODE tags added. Please use normal case for thread titles in future and add your own CODE tags around sequences of code - moderator]