Advertisement
Electgpl

PIC - Control de teclado 4x4

Jun 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.74 KB | None | 0 0
  1. #include <16f883.h>                      
  2. #use delay(int=4000000)                  
  3. #fuses XT,NOWDT                          
  4. #include <LCD.C>                          
  5. char teclaPulsada=0;                      
  6. #byte PORTC = 0x07                        
  7. void leerTeclado(){                      
  8.    output_c(0b11111110);                  
  9.    if(PORTC==0b11101110) teclaPulsada='7';
  10.    if(PORTC==0b11011110) teclaPulsada='4';
  11.    if(PORTC==0b10111110) teclaPulsada='1';
  12.    if(PORTC==0b01111110) teclaPulsada='C';
  13.    delay_ms(50);                          
  14.    output_c(0b11111101);                  
  15.    if(PORTC==0b11101101) teclaPulsada='8';
  16.    if(PORTC==0b11011101) teclaPulsada='5';
  17.    if(PORTC==0b10111101) teclaPulsada='2';
  18.    if(PORTC==0b01111101) teclaPulsada='0';
  19.    delay_ms(50);                          
  20.    output_c(0b11111011);                  
  21.    if(PORTC==0b11101011) teclaPulsada='9';
  22.    if(PORTC==0b11011011) teclaPulsada='6';
  23.    if(PORTC==0b10111011) teclaPulsada='3';
  24.    if(PORTC==0b01111011) teclaPulsada='=';
  25.    delay_ms(50);                          
  26.    output_c(0b11110111);                  
  27.    if(PORTC==0b11100111) teclaPulsada='/';
  28.    if(PORTC==0b11010111) teclaPulsada='X';
  29.    if(PORTC==0b10110111) teclaPulsada='-';
  30.    if(PORTC==0b01110111) teclaPulsada='+';
  31.    delay_ms(50);                          
  32. }                                        
  33. void main(void){                          
  34.    lcd_init();                            
  35.    lcd_gotoxy(1,1);                      
  36.    printf(lcd_putc,"Electgpl Teclado");  
  37.    while(TRUE){                          
  38.       leerTeclado();                      
  39.       lcd_gotoxy(1,2);                    
  40.       printf(lcd_putc,"TECLA...:  %c  ",teclaPulsada);
  41.    }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement