darakilinc
Üye
- Katılım
- 26 Ağu 2009
- Mesajlar
- 33
- Puanları
- 1
- Yaş
- 38
Arkadaşlar merhaba.. Bir kaç haftadır, 4x4 keypad'den mobile keypad yapmaya çalışıyorum. Yani mantık olarak herkezin tahmin edeceği üzere, 2'ye bir kaç saniye içinde 2 kere basıldığında B harfini gösterecek cinsten.. Bir kod yazdım ama çalıştıramadım. Yardımlarınızı bekliyorum. Çok teşekkür ederim..
unsigned short kp, a = 65, oldstate = 0;
char txt[5];
void main() {
Keypad_Init(&PORTB);
Lcd_Init(&PORTD);
Lcd_cmd(LCD_CLEAR);
Lcd_cmd(LCD_CURSOR_OFF);
Lcd_Out(1,1, "M: ");
do {
kp = 0;
do
kp = Keypad_Released();
while(!kp);
do {
switch(kp) {
if case ==4 ;
kp = a; break;
Lcd_Cmd(LCD_MOVE_CURSOR_RIGHT)
if case == 8;
kp = a+1;
delay_ms(1000);
elseif (case != oldstate)
kp = a+2;
delay_ms(1000);
elseif (case != oldstate)
kp = a+3;
Lcd_Cmd(LCD_MOVE_CURSOR_RIGHT)
else {
if case == 12;
kp = a+4;
delay_ms(1000)
elseif (case != oldstate)
kp = a+5;
delay_ms(1000)
elseif (case != oldstate)
kp = a+6;
Lcd_Cmd(LCD_MOVE_CURSOR_RIGHT)
else {
if case == 16;
kp = a+7;
delay_ms(1000)
elseif (case != oldstate)
kp = a+8;
delay_ms(1000)
elseif (case != oldstate)
kp = a+9;
else {
if case == 3;
kp = a+10;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +11;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 12;
else {
if case == 7;
kp = a+13;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +14;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 15;
else {
if case == 11;
kp = a+16;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +17;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 18;
else {
if case == 15;
kp = a+19;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +20;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 21;
else {
if case == 2;
kp = a+22;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +23;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 24;
else {
if case == 6;
kp = a+25;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +26;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 27;
else {
if case == 10;
kp = a+28;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +29;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 30;
else {
if case == 14;
kp = a+31;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +32;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 33;
else {
if case == 1;
kp = a+34;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +35;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 36;
else {
if case == 5;
kp = a+37;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +38;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 39;
else {
if case == 9;
kp = a+40;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +41;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 42;
else {
if case == 13;
kp = a+43;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +44;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 45;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
} while(1)
Lcd_Chr(1,10,kp);
WordtoStr(kp, txt);
}
unsigned short kp, a = 65, oldstate = 0;
char txt[5];
void main() {
Keypad_Init(&PORTB);
Lcd_Init(&PORTD);
Lcd_cmd(LCD_CLEAR);
Lcd_cmd(LCD_CURSOR_OFF);
Lcd_Out(1,1, "M: ");
do {
kp = 0;
do
kp = Keypad_Released();
while(!kp);
do {
switch(kp) {
if case ==4 ;
kp = a; break;
Lcd_Cmd(LCD_MOVE_CURSOR_RIGHT)
if case == 8;
kp = a+1;
delay_ms(1000);
elseif (case != oldstate)
kp = a+2;
delay_ms(1000);
elseif (case != oldstate)
kp = a+3;
Lcd_Cmd(LCD_MOVE_CURSOR_RIGHT)
else {
if case == 12;
kp = a+4;
delay_ms(1000)
elseif (case != oldstate)
kp = a+5;
delay_ms(1000)
elseif (case != oldstate)
kp = a+6;
Lcd_Cmd(LCD_MOVE_CURSOR_RIGHT)
else {
if case == 16;
kp = a+7;
delay_ms(1000)
elseif (case != oldstate)
kp = a+8;
delay_ms(1000)
elseif (case != oldstate)
kp = a+9;
else {
if case == 3;
kp = a+10;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +11;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 12;
else {
if case == 7;
kp = a+13;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +14;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 15;
else {
if case == 11;
kp = a+16;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +17;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 18;
else {
if case == 15;
kp = a+19;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +20;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 21;
else {
if case == 2;
kp = a+22;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +23;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 24;
else {
if case == 6;
kp = a+25;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +26;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 27;
else {
if case == 10;
kp = a+28;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +29;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 30;
else {
if case == 14;
kp = a+31;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +32;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 33;
else {
if case == 1;
kp = a+34;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +35;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 36;
else {
if case == 5;
kp = a+37;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +38;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 39;
else {
if case == 9;
kp = a+40;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +41;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 42;
else {
if case == 13;
kp = a+43;
delay_ms(1000)
elseif (case !=oldstate)
kp = a +44;
delay_ms(1000)
elseif (case !=oldstate)
kp = a + 45;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
} while(1)
Lcd_Chr(1,10,kp);
WordtoStr(kp, txt);
}