PDA

View Full Version : photo resitor



wiresalot
03-04-2010, 05:31 AM
Hello.

How do I use the photo resistor like a dusk till dawn photo cell? Either ON or OFF in the code?

Thanks.

wiresalot

Mike Green
03-04-2010, 05:57 AM
Read the chapters in the "BASIC Stamp Syntax and Reference Manual" on the RCTIME statement. This can be used to measure the resistance of the photoresistor. Experiment with different light levels. You'll find a resistance threshold for your photocell that you can use to distinguish between on and off.

www.parallax.com/tabid/440/Default.aspx (http://www.parallax.com/tabid/440/Default.aspx)

wiresalot
03-04-2010, 06:03 AM
I got the "What is a micro controller" from Radio Shack I dont think I have a manual called "BASIC Stamp Syntax and Reference Manual" Could point me to this reference.

Thanks

wiresalot

Mike Green
03-04-2010, 06:07 AM
Look at the link I gave you.

wiresalot
03-04-2010, 06:11 AM
Downloading it now, Thanks again!!

wiresalot

wiresalot
03-09-2010, 05:02 AM
All right got it working! I am a newbe at this type of programing.

' {$STAMP BS2}
' {$PBASIC 2.5}
value VAR Word

Main:
DO
HIGH 2
PAUSE 100
RCTIME 2, 1, value ' measure rctime
DEBUG DEC value, CR
IF (value > 400 ) THEN ' evaluate duration
DEBUG "Value was greater than 400 " : HIGH 15
ELSEIF (value = 4000) THEN
DEBUG "Value was equal to 400"
ELSE
DEBUG "Value was less than 400 " : LOW 15
ENDIF
DEBUG CR, CR
PAUSE 1000
LOOP

Does my programing look ok?

Thanks
wiresalot

Mike Green
03-09-2010, 06:38 AM
OK means different things to different people. That it works and works as you would like is perhaps the most important. A style issue ... indenting is very important for readability. You used cut and paste to put your program into your message. That causes any indenting to disappear because of how the forum software works. If you want to keep the formatting, use the "code" brackets, "[ code ]" to start a block of code and "[ /code ]" to end the block (without the extra spaces). Even better for larger hunks of code is to use the forum's Attachment Manager that you get by using the Post Reply button rather than the Quick Reply box.

silverback
03-09-2010, 07:20 AM
DEBUG "Value was greater than 400 " : HIGH 15
ELSEIF (value = 4000) THEN
DEBUG "Value was equal to 400"




do you want (value = 4000) in the elseif statement?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If you convince yourself that something is impossible before you even try; you are sure to prove yourself right.

wiresalot
03-10-2010, 06:34 AM
I dont know, still reading how to program. Not exactly sure what the ELSEIF comand does yet!

Thanks

wiresalot

Mike Green
03-10-2010, 07:02 AM
ELSEIF is just like using ELSE and IF separately except that you don't need a lot of ENDIF statements at the end. Look at the description and examples of the IF THEN ELSE statements in the BASIC Stamp Syntax and Reference Manual.

NWCCTV
03-10-2010, 08:21 AM
Hey Mike, How come you don't work for Parallax? You seem to know alot about everything they sell, and would seem to be an invaluable asset to them!!!!! Kudos to you for all the help you provide.