Shop OBEX P1 Docs P2 Docs Learn Events
photo resitor — Parallax Forums

photo resitor

wiresalotwiresalot Posts: 40
edited 2010-03-10 01:21 in BASIC Stamp
Hello.

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

Thanks.

wiresalot

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-03 22:57
    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
  • wiresalotwiresalot Posts: 40
    edited 2010-03-03 23:03
    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 GreenMike Green Posts: 23,101
    edited 2010-03-03 23:07
    Look at the link I gave you.
  • wiresalotwiresalot Posts: 40
    edited 2010-03-03 23:11
    Downloading it now, Thanks again!!

    wiresalot
  • wiresalotwiresalot Posts: 40
    edited 2010-03-08 22:02
    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 GreenMike Green Posts: 23,101
    edited 2010-03-08 23:38
    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, "[noparse][[/noparse] code ]" to start a block of code and "[noparse][[/noparse] /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.
  • silverbacksilverback Posts: 40
    edited 2010-03-09 00:20
    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.
  • wiresalotwiresalot Posts: 40
    edited 2010-03-09 23:34
    I dont know, still reading how to program. Not exactly sure what the ELSEIF comand does yet!

    Thanks

    wiresalot
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-10 00:02
    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.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-03-10 01:21
    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.
Sign In or Register to comment.