Shop OBEX P1 Docs P2 Docs Learn Events
TLS235R Demo Code for BS2 — Parallax Forums

TLS235R Demo Code for BS2

Steve KSteve K Posts: 3
edited 2012-09-01 16:05 in Accessories
I bought a couple of TSL235R and TLS237 but I cannot find any Demo Code for BS2 it seems that Parallax does not supply demo code on the download site and I do not see any in the forums. I don't know where to start.

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2012-09-01 11:25
    Welcome to the forums!

    Here is some code I had for the old TSL230R Light-to-Frequency converter...
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '-----Define variables, set status of pins-----
    x VAR Word
    cnt VAR Word
    '-----Constant declarations------
    S0 PIN 0 'Sensitivity selection pins
    S1 PIN 1
    In PIN 2 'TSL230R output pin
    '-----Program Start-----
    LOW S0 'Set sensitivity pins (S0,S1) to x10
    HIGH S1
    '-----Main program loop-----
    FOR x = 1 TO 2000
      COUNT In, 100, cnt 'COUNT on P2 FOR 100 ms, store value in cnt
      DEBUG HOME, DEC5 cnt 'Display value of cnt as a decimal
    NEXT
    END
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-09-01 11:36
    The some sample code for the TSL230 in this N&V article:

    It should also work with the two devices you have.

    -Phil
  • Steve KSteve K Posts: 3
    edited 2012-09-01 16:05
    Thank you both Ron Cazpala and Phil Pilgrim I had seen code for the TSL230 but because the pin-out was so different (3 pins on the TSL235 / 7 and 8 pins on the TSL230 ) I didn't even try it. But after you suggested that code I just ignored the sensitivity pins and the code works fine.

    Both these code snippets work:
    They're pretty much the same
    Thanks again

    ' {$STAMP BS2e}
    ' {$PBASIC 2.5}
    '
    Define variables, set status of pins
    x VAR Word
    cnt VAR Word
    '
    Constant declarations
    'S0 PIN 0 'Sensitivity selection pins
    'S1 PIN 1
    In PIN 8 'TSL230R output pin
    '
    Program Start
    'LOW S0 'Set sensitivity pins (S0,S1) to x10
    'HIGH S1
    '
    Main program loop
    READER:
    FOR x = 1 TO 2000
    COUNT In, 100, cnt 'COUNT on P2 FOR 100 ms, store value in cnt
    DEBUG HOME, DEC5 cnt 'Display value of cnt as a decimal
    NEXT
    GOTO READER
    END

    and
    ' {$STAMP BS2e}
    TSL230 CON 8
    light VAR Word
    LOOP:
    COUNT TSL230,100,light
    DEBUG HOME,DEC5 light,CR
    PAUSE 100
    GOTO LOOP
Sign In or Register to comment.