document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2.  
  3.  
  4. // LCD module connections
  5. sbit LCD_RS at LATD2_bit;
  6. sbit LCD_EN at LATD3_bit;
  7. sbit LCD_D4 at LATD4_bit;
  8. sbit LCD_D5 at LATD5_bit;
  9. sbit LCD_D6 at LATD6_bit;
  10. sbit LCD_D7 at LATD7_bit;
  11.  
  12. sbit LCD_RS_Direction at TRISD2_bit;
  13. sbit LCD_EN_Direction at TRISD3_bit;
  14. sbit LCD_D4_Direction at TRISD4_bit;
  15. sbit LCD_D5_Direction at TRISD5_bit;
  16. sbit LCD_D6_Direction at TRISD6_bit;
  17. sbit LCD_D7_Direction at TRISD7_bit;
  18. // End LCD module connections
  19.  
  20. char txt1[] = "GreenDigit\'s";
  21. char txt2[] = "MultiMeter";
  22. char txt3[] = "Lcd4bit";
  23. char txt4[] = "example";
  24.  
  25. //char i;                              // Loop variable
  26.  
  27. sbit Switch at RB0_bit;
  28. char message1[] = "Capacitance";
  29. char message2[] = "Meter";
  30. unsigned int T_Value, Num;
  31. unsigned short i, j, TimerValue, OverRange = 0;
  32. char Capacitance[] = "00.000 uF";
  33.  
  34.  
  35. void Display_Cap(unsigned int n){
  36.   Capacitance[0] = n/10000 + 48;
  37.   Capacitance[1] = (n/1000)%10 + 48;
  38.   Capacitance[3] = (n/100)%10 + 48;
  39.   Capacitance[4] = (n/10)%10 + 48;
  40.   Capacitance[5] = (T_Value*10)/153 + 48;
  41.   Lcd_Cmd(_Lcd_Clear);
  42.   Lcd_Out(1, 1, "C = ");
  43.   Lcd_Out(1, 5, Capacitance);
  44. }
  45.  
  46.  
  47. void Move_Delay() {                  // Function used for text moving
  48.   Delay_ms(700);                     // You can change the moving speed here
  49. }
  50.  void interrupt(void){
  51.   if (CMIF == 1)   // Check if INTF flag is set
  52.    {
  53.  
  54.     IFS1.CMIF_bit = 0;
  55.     Lcd_Out(1,5,"Yes Yes");
  56.    }
  57.   }
  58. void Init()
  59. {
  60.   TRISD = 0;
  61.   PORTD = 0;
  62.   TRISB = 0x18;
  63.  
  64.   CM1CON = 0b10000000100000000;
  65.   CVRCON = 0x00;
  66.   IEC1 &= 2;
  67.   /*CM1CON.CEN = 1;
  68.   CM1CON.COE = 0;
  69.   CM1CON.CPOL = 0;
  70.   CM1CON.CEVT = 0;
  71.   CM1CON.EVPOL = 0b10;
  72.   CM1CON.CREF = 0;
  73.   CM1CON.CCH = 0b00;
  74.   CVRCON.CVREN = 0;
  75.   CVRCON.CVROE = 0;*/
  76.   IEC1.CMIE = 1;
  77.   Lcd_Init();
  78.   Lcd_Cmd(_Lcd_Clear);
  79.   Lcd_Cmd(_LCD_CURSOR_OFF);
  80.   Lcd_Out(1,3,txt1);                 // Write text in first row
  81.   Lcd_Out(2,4,txt2);                 // Write text in second row
  82. }
  83.  
  84. void main()
  85. {
  86.  
  87.   char cap_size;
  88.  
  89.   Init();
  90.   Delay_ms(2000);
  91.   Lcd_Cmd(_Lcd_Clear);
  92.   Lcd_Out(1,3,message1);
  93.   Delay_ms(2000);
  94.   Lcd_Cmd(_Lcd_Clear);
  95.  
  96.   while(1)
  97.   {
  98.    if(C1OUT)
  99.    {
  100.  
  101.     Lcd_Out(1,5,"High");
  102.    }
  103.    else
  104.    {
  105.     Lcd_Out(1,5,"Low ");
  106.    }
  107.   }
  108.  
  109. }
');