Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/05/05 07:14
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#98844 - Try this, It works and it's cheap
Responding to: ???'s previous message
Try this, It is not very accurate, but it works.
And it is cheap.
Choose R2 to get a result of 253 in the dark.
To get another range change C1.
Have a nice day.
Robert.

   + 5V
   |
   +---------+
   |         |
   / R1      / R2
   / LDR     / About 33 K
   /         /
   /         /
   |         |
   +---------+-------> I/O PORT 
   |
   =   C1: 200 nF
   |
   |
   + GND	 


; ***************************************
; * Sense light
; ***************************************

LDR       BIT   P3.3
LICHT     DATA  5Eh

GETLIGHT: CLR   LDR       ; Discharge capacitor
          MOV   A,#100    ; Wait until empty
WACHT:    DJNZ  ACC,WACHT ; A is zero
	  SETB  LDR	  ; C starts loading 
  	  
LDR10:	  JB    LDR,LDR20 ; It is high 
 	  INC   A         ; Count the time it takes  
	  JNZ   LDR10     ; te get high, Overflow   
	  DEC   A	  ; result is 255
 
LDR20:	  MOV   LICHT,A   ; Save value
	  RET

Result:
0	Very light
4       Near lamp
12      Normal room
12-200  Getting darker
250-255 Complete dark


List of 33 messages in thread
TopicAuthorDate
Detecting Light with 8051            01/01/70 00:00      
   detecting light            01/01/70 00:00      
      Too specific            01/01/70 00:00      
   have a peek            01/01/70 00:00      
   TAOS inc            01/01/70 00:00      
      simple and cheap            01/01/70 00:00      
         Twilight Switch?            01/01/70 00:00      
         possible schematic            01/01/70 00:00      
            Add            01/01/70 00:00      
               re:add            01/01/70 00:00      
                  NO !            01/01/70 00:00      
                     updated schematic            01/01/70 00:00      
            possible, but not goog            01/01/70 00:00      
               Consensus!            01/01/70 00:00      
                  a comparator with hysteresis constitutes            01/01/70 00:00      
                     Better with            01/01/70 00:00      
                        a 555 ....            01/01/70 00:00      
                           555...            01/01/70 00:00      
         The simplest solution would be...            01/01/70 00:00      
            and...            01/01/70 00:00      
   Try this, It works and it's cheap            01/01/70 00:00      
      how do you know?            01/01/70 00:00      
         OT - you are fully right erik            01/01/70 00:00      
            that is not the issue            01/01/70 00:00      
               What is diddelysquat            01/01/70 00:00      
                  http://wordwebonline.com/en/DIDDLYSQUAT            01/01/70 00:00      
         Because I build it            01/01/70 00:00      
            nobody disputes that, but that does not            01/01/70 00:00      
            re:you built it            01/01/70 00:00      
               and thus Kai states "it's not clear, wh            01/01/70 00:00      
                  re:            01/01/70 00:00      
                     Yes-ish            01/01/70 00:00      
                     Isn't it funny...            01/01/70 00:00      

Back to Subject List