© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 5 of 52
Operation with the BASIC Stamp
This section explains how to use the TSL1401-DB directly with a BASIC Stamp. If you have the
MoBoStamp-pe BASIC Stamp 2pe motherboard, you can skip this section and proceed to the section
titled “Operation with the MoBoStamp-pe”.
Connection
The following illustration shows how to connect the TSL1401-DB to a BASIC Stamp, using Parallax’s
Board of Education and a DB-Expander board:
Vdd
Vin
Vss
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
The signal pinouts and port usage shown above are consistent with the examples to follow in this section.
You can also use the DB-Extension Cable (p/n 500-28301) to separate the TSL1401-DB from the DB-
Expander board if you need to.
Image Acquisition
The output of the TSL1401R is an analog signal, but the BASIC Stamp does not have analog input
capability (except via RCTIME, which isn’t fast enough to read 128 pixels). How, then, is it possible to use
this device with a BASIC Stamp? We do it by connecting the
AO
signal directly to one of the Stamp’s
digital inputs. When done this way, the BASIC Stamp will threshold the analog input. Anything over about
2 volts will read as a
1
; anything under, as a
0
. By treating the signal this way, it’s possible to input a
string of
1
s and
0
s that represent light and dark portions of the “scene” being recorded. A complete
scan, then, would require 128 bits of data (i.e. 16 bytes, or 8 words), which the BASIC Stamp can
accommodate handily.
Once these bits have been read in, it’s possible to analyze “features” of the scene by looking for groups
of light and dark pixels. For example, if you wanted to measure the width of a light object against a dark
background, you could read in the image, then count the number of “1” bits in the data. Likewise, if you
wanted sense the edge of a “web” (e.g. paper in a paper mill) to keep the web on track, you would look
for the first occurrence of a light or dark pixel in each scan.