Advertisement
Tempist

Fuser-Manual

Oct 22nd, 2019
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.44 KB | None | 0 0
  1. #include <header.h>
  2. #device adc=10
  3. #include <responder.h>
  4. #fuses HS,NOLVP,NOWDT,NOPROTECT
  5. #use delay(clock=20000000)
  6. #define use_portb_kbd TRUE
  7. #include <drivermodule.c>
  8. #include <driverscan.c>
  9. #include "readwrite.c"
  10. #use rs232(baud=9600,parity=N,xmit=PIN_c6,rcv=PIN_c7,bits=8,stream=GSM)
  11. int c[4];
  12. int count=0;
  13. int j;
  14. void gsm_ini()
  15. {
  16.    delay_ms(1000);
  17.    fprintf(GSM,"AT\r\n");
  18.    fputc(0x0D,GSM);
  19.    fputc(0x0A,GSM);
  20.    delay_ms(3000);
  21.    fprintf(GSM,"AT+CMGF=1\r\n");
  22.    fputc(0x0D,GSM);
  23.    fputc(0x0A,GSM);
  24.    delay_ms(3000);
  25. }  
  26. void send_sms()
  27. {
  28.    delay_ms(1000);
  29.    fputc(0x19,GSM);
  30.    delay_ms(3000);
  31.    fputc(0x1A,GSM);
  32. }
  33. void send_sms_num()
  34. {
  35.      fprintf(GSM,"AT+CMGS=\"+number\"\r\n"); //Make sure at the "+number\" that you change number to the actual client
  36.    fputc(0x0D,GSM);
  37.    fputc(0x0A,GSM);
  38.    delay_ms(3000);
  39.    fprintf(GSM,"theft alert!!! ");
  40.    send_sms();
  41. }
  42.  
  43. int readin()
  44. {int val;
  45. if(input(PIN_C4))
  46. val=getval();
  47. else
  48. val=kbd_getc();
  49. return val;
  50. }
  51.  
  52. void get_code()
  53. {int k=0;
  54. int i=0;
  55. lcd_putc('\f');
  56. lcd_gotoxy(1,1);
  57.  lcd_putc("ENTER KEY");
  58.  lcd_gotoxy(1,2);
  59. while(i<4)
  60.   {k = readin();          
  61.       if(k!=0)                    
  62.       { c[i]=k;
  63.          i++;
  64.          lcd_putc(k);            
  65.          k=0;                    
  66.          delay_ms(250);        
  67.       }
  68.       delay_ms(1);
  69.   }
  70. }
  71.  
  72. void main()
  73. {int s[4]={'1','2','3','4'};
  74. int32 x;
  75. char n;
  76. setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1|RTCC_8_bit);
  77.  output_high(PIN_C5);
  78.    
  79.    delay_ms(50);
  80.  
  81.    lcd_init();                   // Turn LCD ON, along with other initialization commands
  82.    kbd_init();    // Initialize Keypad
  83.  delay_ms(100);
  84.   while(1)
  85.    {
  86.    if(count<3)
  87.    {
  88.       get_code();
  89.    count++;
  90.    if(c[0]==s[0]&&c[1]==s[1]&&c[2]==s[2]&&c[3]==s[3])
  91.    {
  92.    output_high(PIN_C0);
  93.     break;
  94.    }
  95.    
  96.    else
  97.    {
  98.    lcd_putc('\f');
  99. lcd_gotoxy(1,1);
  100.  lcd_putc("CODE ERROR");
  101.   delay_ms(1000);  
  102.     }
  103.    }
  104. else
  105.  { gsm_ini();
  106.   send_sms_num();
  107.   for(j=0;j<10;j++)
  108.  {output_high(PIN_C1);
  109. delay_ms(500);
  110.  output_low(PIN_C1);
  111. delay_ms(500);
  112. }
  113.    for(j=0;j<120;j++)
  114.  delay_ms(1000);
  115.  count=0;
  116.  }
  117.      
  118.    } lcd_putc('\f');
  119. lcd_gotoxy(1,1);
  120.  lcd_putc("CODE ACCEPTED");
  121. delay_ms(100);
  122. lcd_putc('\f');
  123.  
  124. while(1)
  125. { set_timer0(0);
  126. delay_ms(1000);
  127. x = GET_TIMER0();
  128. lcd_putc("\fSpeed : ");
  129. n=x/10 + '0';
  130. lcd_putc(n);
  131. n=x%10 + '0';
  132. lcd_putc(n);
  133. lcd_putc("kmph");
  134. }  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement