Guide

Copyright © Parallax Inc. 4-Directional Tilt Sensor (#28036) v1.0 12/20/2010 Page 3 of 4
Connection Diagrams
For use with the BASIC Stamp and Propeller P8X32A example programs listed below. Note: Maximum
output signal voltage approaches power supply voltage, so use the same voltage level for microcontroller
and sensor supply.
*Vdd = 3.3V for Propeller Applications, 5V for BASIC Stamp Applications
BASIC Stamp
®
Example Code
4DirectionalTiltSesnor_Simple.bs2 displays the output states of both phototransistors. It uses the Debug
Terminal, which is built into the BASIC Stamp Editor software. The software is a free download from
www.parallax.com/basicstampsoftware
.
' 4DirectionalTiltSensor_Simple.bs2
' Displays output states of both phototransistors
' {$STAMP BS2}
' {$PBASIC 2.5}
PAUSE 1000
DO
DEBUG HOME, "Phototransistor 1: ", BIN1 IN0, CR,
"Phototransistor 2: ", BIN1 IN1
PAUSE 50
LOOP
Propeller
P8X32A Example Code
4DirectionalTiltSesnor_Simple.spin displays the current output states of both phototransistors. It uses the
Parallax Serial Terminal to display the device output. The object and the Parallax Serial Terminal itself are
included with the with the Propeller Tool v1.2.7 or higher, which is available from the Downloads link at
www.parallax.com/Propeller
.
'' 4DirectionalTiltSensor_Simple.spin for P8X32A
'' Displays output states of both phototransistors
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
OBJ
pst : "Parallax Serial Terminal.spin"