Shop OBEX P1 Docs P2 Docs Learn Events
laser trip line code help needed — Parallax Forums

laser trip line code help needed

CordcoleCordcole Posts: 16
edited 2010-10-09 17:32 in BASIC Stamp
i have a basic stamp homework, for a Halloween project i need to have a laser beam hit the photo cell and trigger a relay for 3 seconds. the pins i use are not a concern. could i have help with some code

cheers

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-10-02 17:42
    Do you have the laser and photocell part working? What is the output of the photocell in relation to ground?
  • ercoerco Posts: 20,256
    edited 2010-10-02 17:55
    Easy as cake. Use a Radio Shack phototransistor (ptx) instead of a photocell, it's a better match for the laser's red wavelengths. Photocells are mainly responsive to yellow-green light.

    The hardest part is mounting the laser and ptx firmly so they stay in alignment. Even the Shack has a good $2 ptx: http://www.radioshack.com/product/index.jsp?productId=2049724

    You can do a simple voltage divider with a series 1 meg resistor, feed that into a stamp and check for a high-low transistion when the beam is broken.

    Piece of pie.
  • logan996logan996 Posts: 281
    edited 2010-10-03 05:40
    Wait erco, couldnt he trim the phototransistor down to a flat edge? so the laser can hit it better.
  • ercoerco Posts: 20,256
    edited 2010-10-03 07:50
    Works either way, no need to trim flat. That ptx housing is sort of a lens, but as long as you hit any part of the housing with a laser, the sensor will know it, and know it well.
  • CordcoleCordcole Posts: 16
    edited 2010-10-05 13:33
    ok after some testing, the " time " with the laser schiming on the photo cell is 1 and when it isnt on the photo cell it is 2000-3000. now that i have the phot cell on pin 2 i need to be able to have when the beam is broken it sets of pins 10, 9, 8. and the goes for 3 seconds and the it loops back to the begining thanks
    755 x 159 - 8K
    441 x 226 - 7K
  • FranklinFranklin Posts: 4,747
    edited 2010-10-05 15:39
    try something like
    high (pin number)
    pause 3000
    goto start
  • CordcoleCordcole Posts: 16
    edited 2010-10-05 17:51
    actually i think
    do
    high 2
    pause 100
    rctime 2, 1, time 
    
    
    IF (IN2 = 2000) THEN
    
      HIGH 10 
      PAUSE 3000
      LOW 10
      PAUSE 1
    ELSE
      PAUSE 1       
     ENDIF
    
    LOOP
    
  • ercoerco Posts: 20,256
    edited 2010-10-05 19:40
    Way to answer your own question! How does it work?
  • AmaralAmaral Posts: 176
    edited 2010-10-05 20:14
    IN2 = 2000 ??? where does that comes from ?
  • CordcoleCordcole Posts: 16
    edited 2010-10-06 04:27
    that was the high and yes it should be 1, ( i am still a noob )
  • CordcoleCordcole Posts: 16
    edited 2010-10-09 16:19
    that didnt work any help please
  • ercoerco Posts: 20,256
    edited 2010-10-09 17:32
    Maybe something more like:

    time var word

    do
    high 2
    pause 100
    rctime 2, 1, time


    IF (time>2000) THEN

    HIGH 10
    PAUSE 3000
    LOW 10
    PAUSE 1
    ELSE
    PAUSE 1
    ENDIF

    LOOP



    Not sure what you're trying to accomplish with that else/pause 1.

    A quicker way to get to Carnegie Hall:


    a:
    high 2
    pause 1
    rctime 2, 1, w0
    IF w0<2000 THEN a
    HIGH 10
    PAUSE 3000
    LOW 10
    goto a
Sign In or Register to comment.