Advertisement
Electgpl

PIC - Teléfono Celular con SIM900

Jun 19th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.08 KB | None | 0 0
  1. //Telefono Celular para modulo SIM900
  2. //Comando para llamar: ATD + [NUMERO]
  3. //Comando para colgar: ATH0
  4. //LCD 16x2 en 4bit
  5. //Teclado 4x4
  6. //Botones de llamada y borrado
  7. #include <16f883.h>
  8. #use delay(int=4000000)
  9. #fuses XT,NOWDT
  10. #include <LCD.C>
  11. #use rs232(baud=9600,xmit=pin_a0,rcv=pin_a1,bits=8,parity=N)
  12. char teclaPulsada=0;
  13. #byte PORTC = 0x07
  14. void leerTeclado(){
  15.    teclaPulsada='x';
  16.    output_c(0b11111110);
  17.    if(PORTC==0b11101110) teclaPulsada='1';
  18.    if(PORTC==0b11011110) teclaPulsada='4';
  19.    if(PORTC==0b10111110) teclaPulsada='7';
  20.    if(PORTC==0b01111110) teclaPulsada='*';
  21.    delay_ms(50);
  22.    output_c(0b11111101);
  23.    if(PORTC==0b11101101) teclaPulsada='2';
  24.    if(PORTC==0b11011101) teclaPulsada='5';
  25.    if(PORTC==0b10111101) teclaPulsada='8';
  26.    if(PORTC==0b01111101) teclaPulsada='0';
  27.    delay_ms(50);    
  28.    output_c(0b11111011);
  29.    if(PORTC==0b11101011) teclaPulsada='3';
  30.    if(PORTC==0b11011011) teclaPulsada='6';
  31.    if(PORTC==0b10111011) teclaPulsada='9';
  32.    if(PORTC==0b01111011) teclaPulsada='#';
  33.    delay_ms(50);
  34. }
  35. void borrado(){
  36.    lcd_gotoxy(1,1);
  37.    printf(lcd_putc,"Cortando...");
  38.    delay_ms(100);
  39.    printf("ATH0;");
  40. }
  41. void main(void){
  42.    inicio:
  43.    char telefono[11];
  44.    lcd_init();
  45.    lcd_gotoxy(1,1);
  46.    printf(lcd_putc,"    Electgpl    ");
  47.    lcd_gotoxy(1,2);
  48.    printf(lcd_putc,"Telefono Celular");
  49.    delay_ms(1500);
  50.    lcd_init();
  51.    lcd_gotoxy(1,1);
  52.    printf(lcd_putc,"Listo...");
  53.    delay_ms(500);
  54.    lcd_init();  
  55.    lcd_gotoxy(1,2);
  56.    printf(lcd_putc,"[CALL]     [END]");
  57.    int i=0;
  58.    while(TRUE){
  59.       leerTeclado();
  60.       if(teclaPulsada!='x'){
  61.          telefono[i]=teclaPulsada;
  62.          i++;
  63.       }  
  64.       lcd_gotoxy(1,1);
  65.       printf(lcd_putc,"%s",telefono);
  66.       if(input(PIN_A2)==1){
  67.          telefono="         ";
  68.          borrado();
  69.          goto inicio;
  70.       }  
  71.       if(input(PIN_A1)==1){
  72.          if(input(PIN_A2)==1){
  73.             telefono="         ";
  74.             borrado();
  75.             goto inicio;
  76.          }
  77.          printf("ATD + %s;",telefono);
  78.          i=0;  
  79.       }  
  80.    }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement