GLCD 128x64 with PIC18F4620

  • Share:




GLCD 128x64 with PIC18F4620 Testing 
This project is testing GLCD 128x64 with PIC18F4620 micro controller use CCS compiler.

Hardware
Microchip PIC18F4620 Microcontroller
LCD Graphic Displays/Modules
GRAPHIC LCD 128*64 DOT STN NEGATIVE BLUE WHITE LED BLACK LIGHT

Software
#include    <18F4620.h>

#define     TxD   PIN_C6
#define     RxD   PIN_C7
#device     ADC=10

#fuses      HS,NOWDT,NOPROTECT,NOLVP
#use        delay (clock = 20000000)
#use        rs232(baud = 9600, xmit = TxD, rcv = RxD, bits = 8)   // Port C
#define     Vbe      0.00488758        // Constant Parameter

#include    <include\font.c>
#include    <include\k0108.c>

//-----------------------------------------------------------------------------//
void init_io (void)
{

      setup_comparator(NC_NC_NC_NC);

      set_tris_a (0b00000011);   // ADC CH0, CH1
      set_tris_b (0b00000000);   //Port B = output
      set_tris_c (0b10000000);   //Port C = output
                                 /*
                                       RC6 = TxD
                                       RC7 = RxD
                                 */
}
//-----------------------------------------------------------------------------//
void main() {

      int16 value_adc1,value_adc2;

      float volt1, volt2;
      unsigned int bar1,bar2;
      char buf[24];
     
      init_io ();

      setup_adc_ports(ALL_ANALOG);
      setup_adc      (ADC_CLOCK_INTERNAL);

      printf ("\f\n\rSoftware Compile Date : ");
      printf (__DATE__); printf (" / ");
      printf (__TIME__);
      printf ("\n\rBy microcontrollerkits.blogspot.com/\n\n");

      while (1)
      {

         lcd ();
        
         while (1)
         {
              set_adc_channel(0); 
              value_adc1 = Read_ADC();
              volt1 = (Vbe * (float)value_adc1);
              delay_ms (100);
             
              set_adc_channel(1); 
              value_adc2 = Read_ADC();
              volt2 = (Vbe * (float)value_adc2);
              delay_ms (100);

           
              bar1 = (int8)(volt1*10);
              bar2 = (int8)(volt2*10);
              //send to RS232
              printf ("\rA/D(1) -> %1.2f Volt and A/D(2) -> %1.2f Volt",volt1,volt2);

              // Display on LCD
              lcd_gotoxy (0,6);
              lcd_progress_high (bar1,87);
              lcd_progress_high (bar2,104);
              lcd_gotoxy (0,5);
              sprintf (buf,"A/D(0) = %1.2f",volt1);
              lcd_putstring (buf);
             
              lcd_gotoxy (0,6);
              sprintf (buf,"A/D(1) = %1.2f",volt2);
              lcd_putstring (buf);
              delay_ms (100);
         };

      };

}

Related Stories

Start Conversation

Tidak ada komentar

Posting Komentar