i' using the following code to read 2 LDRs' and change the direction of a small robot. The code is based on the tutorial: http://www.rentron.com/Micro-Bot/CDS.htm


Code:
eyes:

gosub check_LDR ' get LDR RC values

select case light_state

case 1

    IF LDR_Right_Val > LDR_Left_Val THEN	   'if right brighter than left  	 		
			
				if panic_flag = 1 then		   'is it in hide mode?
				    eyes_output = right  	   'yes - right
				else
					eyes_output = left 		   'no - left
				end if		
	  	 'ENDIF
   else
 	 	 light_state = 2		  			   'goto next state
   end if
 
case 2 

   if LDR_Left_Val > LDR_Right_Val THEN	   	   'if left brighter than right
		 
				if panic_flag = 1 then		   'is it in hide mode?
				    eyes_output = left         'Yes - left
				else
					eyes_output = right        'No - right
				end if		
   else
 	 	 light_state = 3		  			   'goto next state
   end if
 
 case 3
 	   	 light_state = 1					   'goto the first state
		 eyes_output = idle	 				   'idle
end select
  
return	  			   						   'return to start






check_LDR:

  HIGH portb.6 'Right_LDR               	  'Make right CDS pin high
  PAUSE 3                      	 	  		  ' Let cap charge
  RCTIME portb.6, 1, LDR_Right_RCdata 		  ' Time & record discharge time 


  HIGH portb.7 'Left_LDR                	  'Make left CDS pin high
  PAUSE 3                      				  ' Let cap charge
  RCTIME portb.7, 1, LDR_Left_RCdata   		  ' Time & record discharge time


LDR_Right_Val = NCD LDR_right_RCdata
LDR_Left_Val =  NCD LDR_left_RCdata

return

i'm using a 220ohm resistor, with 0.1uF caps. The LDRs rated 27k - 94k.


The code works in that if one LDR is covered the the robot turns as required.

However In ambient light it doesnt find the brightest source of light.

Can anyone help with sugestions to improve the sensitivity..


any help is greatly apriciated


thanks

jim