Friday 28 March 2014

SOLDERING AND PROGRAM THE LCD

WEEK 8

Throughout this entire week, I tried to complete the solder and the program which is upgrade with the LCD. the completed program will determine the effectiveness and success of this project. After making several references and corrections, the program which caters to what i wanted was achieved. i then tried to ensure that the program together with the hardware is working perfectly. I use PIC compiler for the software of assembly language that I used in this project. Then used software Winpic800 for download program to PIC microcontroller. The PIC programmer was connected to the computer via serial port/USB Port. Then, the PIC is placed into the programmer socket. At the desktop, the „Winpic800‟ folder is copied and the file of
 Winpic800.exe‟ is selected. My coding is below:

solder the LCD



#include <16f877A.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,PARITY=N)
#fuses hs,noprotect,nowdt,nolvp
#define use_portb_lcd TRUE  // lcd di sambung pada port B
#include<lcd.c>  // default


#byte PORTB=6
#byte PORTC=7
#byte PORTD=8



int buffer[3];
int i;

void detect_card();


void main()
{

   lcd_init();    // default utk LCD

   set_tris_d(0);
   set_tris_c(0b10000011);

    output_low(PIN_d0);
    output_low(PIN_d1);


   output_low(PIN_C2);
   delay_ms(1000);
   output_high(PIN_C2);

   buffer[0]=0;
   buffer[1]=0;
   buffer[2]=0;

   do
   {

            lcd_gotoxy(1,1);
            lcd_putc("     PLEASE     ");
            lcd_gotoxy(1,2);
            lcd_putc("   TOUCH CARD   ");

       detect_card();


       printf("Hex: %X%X%X  ",buffer[2],buffer[1],buffer[0]);
       if(buffer[2]==0x7E&& buffer[1]==0x0D && buffer[0]==0x76)
       {
            lcd_gotoxy(1,1);
            lcd_putc("FARAH NAZIHAH   ");
            lcd_gotoxy(1,2);
            lcd_putc("51211112350     ");

             output_high(pin_d0);
             delay_ms(5000);
             output_low(pin_d0);

            lcd_gotoxy(1,1);
            lcd_putc("     PLEASE     ");
            lcd_gotoxy(1,2);
            lcd_putc("   TOUCH CARD   ");
       }

       else
       {

            lcd_gotoxy(1,1);
            lcd_putc("      SORRY     ");
            lcd_gotoxy(1,2);
            lcd_putc("  INVALID CARD  ");

            output_high(pin_d1);
            delay_ms(3000);
            output_low(pin_d1);

            lcd_gotoxy(1,1);
            lcd_putc("     PLEASE     ");
            lcd_gotoxy(1,2);
            lcd_putc("   TOUCH CARD   ");




       }

   }while(1);
}

void detect_card()
{
      for(i=0; i<26;i++)
      {       while(input(PIN_C0)==1 && input(PIN_C1)==1);
               if(input(PIN_C0)==0 )
               {       if(i!=0 && i != 25)
                        {    shift_left(buffer,3,0); }
               }
               if(input(PIN_C1)==0)
               {        if(i!=0 && i != 25)
                        {shift_left(buffer,3,1); }
               }
               delay_us(500);
      }
}

*after the output relay through the solenoid with active high then LCD will display my ID n my name


No comments:

Post a Comment