This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

4x4 keypad

Hello, i was wondering if anyone could help me, to get my 4x4 keypad scanning function working.
Its supposed to drive each column to zero one at a time and then poll each row in sequence for zeros.

unsigned int scan_key (void) {

int col;

int key_read;

///////////

for(col=0;col++;col=3 ) { ////Go through columns

///////////////////////////////////////////// (GPIO_PORTD_DATA )&=~(0x1<<col);

if (!(GPIO_PORTC_DATA & 0x10)==0)//Polling row0

{ key_read=keypad [0][col]; break; }

///////////////////////////////////////////////// /////////////////////////////////////

if (!(GPIO_PORTC_DATA & 0x20)==0)//Polling row1

{ key_read=keypad[1][col]; break; }

//////////////////////////////////////////////////

if (!(GPIO_PORTC_DATA & 0x40)==0)//Polling row2

{ key_read=keypad[2][col]; break; }

/////////////////////////////////////////////////////////

if (!(GPIO_PORTC_DATA & 0x80)==0)//Polling row3

{ key_read=keypad[3][col]; break; }

}
return key_read; }

0