Documentos de Académico
Documentos de Profesional
Documentos de Cultura
int tecla;
int i;
void teclado(){
for(i=0;i<3;i++){
switch (i) {
case 0:
portb=0b0001;
if(PORTB.F4==1){tecla=1;}
if(PORTB.F5==1){tecla=2;}
if(PORTB.F6==1){tecla=3;}
if(PORTB.F7==1){tecla=10;}
case 1:
portb=0b0010;
if(PORTB.F4==1){tecla=4;}
if(PORTB.F5==1){tecla=5;}
if(PORTB.F6==1){tecla=6;}
if(PORTB.F7==1){tecla=11;}
case 2:
portb=0b0100;
if(PORTB.F4==1){tecla=7;}
if(PORTB.F5==1){tecla=8;}
if(PORTB.F6==1){tecla=9;}
if(PORTB.F7==1){tecla=12;}
case 3:
portb=0b1000;
if(PORTB.F4==1){tecla=13;}
if(PORTB.F5==1){tecla=0;}
if(PORTB.F6==1){tecla=15;}
if(PORTB.F7==1){tecla=16;}
}
}
}
void main(){
CMCON=7;
TRISA=0;
TRISB=0b11110000;
while (1){
teclado();
if (tecla==0){
porta=0b10000000; } //0
if (tecla==1){
porta=0b11111001; } //1
if (tecla==2){
porta=0b01000100; } //2
if (tecla==3){
porta=0b01110000; } //3
if (tecla==4){
porta=0b00111001; } //4
if (tecla==5){
porta=0b00110010; } //5
if (tecla==6){
porta=0b00000011; } //6
if (tecla==7){
porta=0b11111000; } //7
if (tecla==8){
porta=0b00000000; } //8
if (tecla==9){
porta=0b00111000; } //9
}
}
void main() {
CMCON=7;
TRISA=0;
TRISB=0b11110000;
Lcd_Init(); // Initialize LCD