The leds on board indicate printer port status and are very useful in case of debugging. The photo resistor and switches offer interactive signals to the computer.
A 5-V regulator is used to maintain a consistent TTL voltage level for the circuit and the computer printer port. A voltage divider circuit is included to provide a 0.6V differential at Vo for proper LCD operation. ICs 74LS244 and 4k7 resistors are used to limit draining currents from the computer. Bits C1 and C0 are countered inverted in the module to maintain positive logic and hence, be more straightforward for programming. Finally, the photo-resistor monitors lighting conditions via the input port. It sends a high bit when it sees light and, a low when dark.
One of the advantages of using BASIC language is that the software is very simple and English like. Therefore most BASIC programs are self- explanatory. The program starts with declarations of LCD settings. The LCD is initialized as a 8-bit 2-line display unit. It then clears the screen and starts the display at the home position with character increment from left to right for each read/write execution. Text messages are stored in ASCII codes and represent addresses of the LCD RAM character data set. The photosensor feedback bit is continuously being monitored to provide branching decision for the appropriate display action.
PROGRAM LISTING
10 REM LCD 16265 display output routine
20 REM 2 x 16 characters format
30 REM PRT PORT 378h & 37Ah (888 & 890)
100 DEFINT A-Z
110 REM OUT &H303, &H80
115 REM initialization of LCD routine
120 x = &H38: GOSUB 700
130 x = &H1: GOSUB 700
140 x = &H2: GOSUB 700
150 x = &H6: GOSUB 700
160 x = &HC: GOSUB 700
170 PRINT "initialization done"
200 REM routine to write line 1
210 x = &H2: GOSUB 700
220 a1$ = " LCD "
230 FOR i = 1 TO 16
240 char1$ = MID$(a1$, i, 1)
250 x = ASC(char1$): GOSUB 800
260 NEXT i
300 REM routine to write line 2
310 x = &HC0: GOSUB 700
320 a2$ = " TECHNOLOGY "
330 FOR i = 1 TO 16
340 char2$ = MID$(a2$, i, 1)
350 x = ASC(char2$): GOSUB 800
360 NEXT i
370 STOP
380 END
700 REM set1 routine
710 GOSUB 600
720 OUT &H37A, &H2
740 OUT &H378, x
750 OUT &H37A, &H3
760 RETURN
800 REM set2 routine
810 GOSUB 600
830 OUT &H37A, &H6
840 OUT &H378, x
850 OUT &H37A, &H7
860 RETURN
This simple project outlines basic steps in programming a LCD. The printer port interface can greatly facilitate the process. Hopefully this project could bring you hours of enjoyment and keep you in touch with this growing technology. There are unlimited applications for the module: