Hi all,
I need your help in attendance registration project : I decide to register my students attendance automatically where each student has ID card with he's own number printed in barcode format with 11 digits like this "120061235" when we scaned it.
I read alot about barcode reader ps/2 protocol and know how it works and how i can interface with PIC16f877a , but i don't where is the problem I don't know how to display this ID number on an LCD for example
I use the interrupt to get clock
please anyone have an idea how to read barcode reader and display on LCD ?
here is my code:
Include "Modedefs.Bas"
DEFINE LCD_DREG PORTD 'LCD data port
DEFINE LCD_DBIT 4 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTD 'LCD register select port
DEFINE LCD_RSBIT 2 'LCD register select bit
DEFINE LCD_EREG PORTD 'LCD enable port
DEFINE LCD_EBIT 3 'LCD enable bit
DEFINE LCD_BITS 4 'LCD bus size 4 or 8
DEFINE LCD_LINES 4 'Number lines on LCD
DEFINE OSC 4 ' We're using a 4 MHz oscillator
Clr CON 1 ' Serial LCD command to clear LCD
LINE1 CON 128 ' Line #1 of serial LCD
LINE2 CON 192 ' Line #2 of serial LCD
LINE3 CON 148 ' Line #3 of serial LCD
LINE4 CON 212 ' Line #4 of serial LCD
Ins CON 254 ' Instruction for LCD command-mode
symbol SCL = PORTC.3 ' I2C CLOCK pin
symbol SDA = PORTC.4 ' I2C DATA pin
symbol clock_barcode=portb.0
symbol data_barcode=portb.1
input clock_barcode
input data_barcode
output portd.1
symbol but1=portb.2
input but1
portd.1=0
ON INTERRUPT GOTO reg_id
OPTION_REG = %00000101 ; falling edge of clock
pause 2000
INTCON = %10010000 ' Enable RB0 interrupt
Addr Var byte ' 8-bit memory address in EEPROM
EE_ByteOut Var Byte ' Variable whose value is to be stored to EEPROM
EE_ByteIn Var Byte ' Variable for storing the value read from EEPROM
ID var bit[250]
char var byte
countstep var byte
counter var byte
counter=0
TRISD = 0 ' Port D is output
EE_ByteOut=0
lcdout Ins,clr,INS,Line1,"Please Ins. ID card"
Main:
if but1=0 then
lcdout ins,clr,ins,line1,#counter,ins,line2
pause 3000
for countstep=0 to counter
lcdout #id[countstep]
pause 2000
next
counter=0
endif
goto main ' Remain in loop
DISABLE ' Disable interrupts in handler
reg_id:
if clock_barcode=0 then ; test falling edge
id[counter]=data_barcode
endif
counter=counter+1
portd.1=data_barcode ' Turn on LED when interrupted
intcon.1=0 ; reset int
RESUME ' Return to main program
ENABLE ' Enable interrupts after handler
Bookmarks