You are on page 1of 9

///////////////////////////////////TROLLY/////////////////////////

#include<16F877A.h>

#use delay( clock = 20000000 )

#fuses hs , nowdt

#use rs232( baud = 9600 , xmit = PIN_C6 , rcv = PIN_C7 ,BITS = 8 )

#include"lcd.c"

#include<string.h>

#byte TRIS_B = 0x86

#byte TRIS_A = 0x85

#define cancel_button PIN_B6

#define ir PIN_B7

#define buzzer PIN_B0

char msg[] = "\fRFID BASED TROLLEY SYSTEM";

char rfid[11] , *rf , k[5];

int buf = 0 , i = 0 , j ;

int flag = 0 , cancel_flag = 0 , cancel_count = 0 ;

char rcv = 0 ;

char rf_data[2][5] = {"829M","341M"} ;

int16 price[] = { 150 , 200 } ;

int price_ref ;
int16 total = 0 ;

/////////////////////////////////////////////////////////////////////////////////

void price_estimating( int price_ref )

if( cancel_flag == 1 )

total = total - price[price_ref] ;

lcd_putc("\fCANCEL SUCEED") ;

//printf(lcd_putc,"\nRs : %lu",total);

delay_ms(100);

//printf("%lu",total);

//delay_ms(1500);

flag = 0 ;

j=2;

cancel_count = 0 ;

else

total = total + price[price_ref] ;

// printf(lcd_putc,"\nRs : %lu",total);

delay_ms(100);

//printf("%lu",total);
delay_ms(1500);

flag = 0 ;

j=2;

///////////////////////////////////////////////////////////////////////////////////////////////

void calculating( char *rf )

while( j < 2 )

for( i = 0 ; i < 5 ; i++ )

k[i] = rf_data[j][i] ;

delay_ms(50);

if(!strcmp(*k,*rf))

printf(lcd_putc,"\fMatch") ;

price_estimating( price_ref ) ;

delay_ms(1500);

if(strcmp(*k,*rf))
{

j++;

price_ref++ ;

delay_ms(100);

//////////////////////////////////////////////////////////////////////////////////////

void cancel(char *rf)

cancel_flag = 1 ;

while( j < 2 )

for( i = 0 ; i < 5 ; i++ )

k[i] = rf_data[j][i] ;

delay_ms(50);

if(!strcmp(*k,*rf))

printf(lcd_putc,"\fMatch") ;
price_estimating( price_ref ) ;

delay_ms(1500);

if(strcmp(*k,*rf))

j++;

price_ref++ ;

delay_ms(100);

///////////////////////////////////////////////////////////////////////////////////////

void main()

enable_interrupts( global ) ;

enable_interrupts( int_rda ) ;

TRIS_B = 0xf0 ;

lcd_init() ;

lcd_putc("Booting........\nPls wait");
delay_ms(1500);

lcd_putc("\f WELCOME");

delay_ms(1500);

output_low(buzzer) ;

for( i = 0 ; i < 26 ;i++ )

printf(lcd_putc,"%c",msg[i]);

delay_ms(150);

if(i==10)

lcd_putc("\n");

delay_ms(1500);

delay_ms(1500);

while( 1 )

j = price_ref = buf = cancel_flag = 0 ;

output_low(buzzer) ;

printf(lcd_putc,"\fShow Ur RFID") ;

printf(lcd_putc,"\nRs : %lu",total);

delay_ms(500);

if(input(cancel_button))

cancel_count = 1 ;
lcd_putc("\fCANCEL MODE\n SELECTED");

delay_ms(1500);

lcd_putc("\fTAKE PDT FROM\n TROLLY");

delay_ms(1500);

while( flag == 0 && input(ir) )

output_high(buzzer) ;

lcd_putc("\fSHOW RF TAG AND\nPUT TO TROLLEY");

delay_ms(500);

while( flag == 1 )

rf = rfid+8 ;

printf(lcd_putc,"\f%s",rf) ;

delay_ms(1500);

if( cancel_count ==0 )

printf("%s\r",rf) ;

if( cancel_count == 1 )

printf(lcd_putc,"\f%s",rf) ;

printf("c%s\r",rf) ;

cancel(rf);

}
else

calculating( rf );

#int_rda

void isr()

char c ;

c = getc();

rcv = c ;

if( c == '\r' || c == '\n' )

buf = 0 ;

else

rfid[buf] = c ;

flag = 1 ;

}
if( buf < 11 )

buf++ ;

clear_interrupt( int_rda ) ;

You might also like