Page 149 -
P. 149
136 Chapter Nine
Figure 9.18 CdS photoresistor
cell.
The second method involves building a simple PIC 16F84 circuit connected
to an LCD display. The advantage of this circuit is that you can see the
response of the CdS cells under varying light conditions. In addition, you can
see the difference in resistance between the CdS cells when they are held
under the same illumination. This numeric difference of the CdS cells under
exact lighting is used as a fudge factor in the final turtle program. If you just
test the CdS cells with just an ohmmeter, you will end up using a larger fudge
factor for the robot to operate properly.
The schematic for testing the CdS cells is shown in Fig. 9.19. The circuit,
built on a PIC Experimenter’s Board, is shown in Fig. 9.20. The PicBasic Pro
testing program follows:
‘CdS cell test
‘PicBasic Pro program
‘Serial communication 1200 baud true
‘Serial information sent out on port b line 0
‘Read CdS cell #1 on port b line 1
‘Read CdS cell #2 on port b line 7
v1 var byte ‘Variable v1 holds CdS #1 information
v2 var byte ‘Variable v2 holds CdS #2 information
Pause 1000 ‘Allow time for LCD display
main:
pot portb.1,255,v1 ‘Read resistance of CdS #1 photocell
pot portb.7,255,v2 ‘Read resistance of CdS #2 photocell
‘Display information
serout portb.0,1,[$fe,$01] ‘Clear the screen

