4 Directional Tilt Sensor (#28036) Guide 28036

guide-28036

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 4

Web Site: www.parallax.com
Forums: forums.parallax.com
Sales: sales@parallax.com
Technical: support@parallax.com
Office: (916) 624-8333
Fax: (916) 624-8003
Sales: (888) 512-1024
Tech Support: (888) 997-8267
Copyright © Parallax Inc. 4-Directional Tilt Sensor (#28036) v1.0 12/20/2010 Page 1 of 4
4-Directional Tilt Sensor (#28036)
The 4-Directional Tilt Sensor is a perfect accelerometer replacement in those applications which may not
need precise angular feedback. This type of sensor is commonly used in many smart phones and digital
cameras as a cheaper means to adjust the screen display when the device is rotated.
Features
Small 6-pin DIP packaging with
breadboard-friendly 0.1" pin spacing
Easy communication with any
microcontroller
Positional feedback in four directions
Key Specifications
Power Requirements: 3 to 5.5 VDC
Communication Interface: 2-pin
high/low output for four sensor states
Operating temperature: 32 to 122 °F
(0 to 50 °C)
Dimensions: 0.42 x 0.32 x 0.49 in
(1.07 x 0.81 x 1.24 cm)
Application Ideas
Rotating display adjustment
Robotic movement
Tilt sensing for remote controls
Alarm systems
Resources and Downloads
Check for the latest version of this document, free software, and example programs from the 4-
Directional Tilt Sensor product page. Go to www.parallax.com and search 28036.
Theory of Operation
Internally, the 4-Directional Tilt Sensor includes one IR LED, two phototransistors, and a small ball that
moves when the sensor is rotated. Depending on the orientation of the sensor, the two phototransistors
will output high or low signals depending whether light is detected or not. New locations are triggered
when the sensor is rotated roughly 30° toward the new position.
The chart below depicts the cylinder location when rotating the sensor, and the output states of each
phototransistor during revolution.
Copyright © Parallax Inc. 4-Directional Tilt Sensor (#28036) v1.0 12/20/2010 Page 2 of 4
Location
Phototransistor
1 Phototransistor
2
A 0 0
B 1 0
C 1 1
D 0 1
Items of Note:
When the sensor is lying flat and only acted on by g-forces, the cylinder will be in Location C.
Upon startup and when lying flat, the sensor remains in the last location before shutdown. Once
movement is detected, the sensor will respond normally.
Pin Definitions and Ratings
Pin Name Type Function
1 OUT2* O Output state of phototransistor 2
2 Vdd* P Supply Voltage -> 3.0 - 5.5V
3 GND G Ground -> 0V
4 GND G Ground -> 0V
5 Vdd* P Supply Voltage -> 3.0 - 5.5V
6 OUT1* O Output state of phototransistor 1
Pin Type: P = Power, G = Ground, I = Input, O = Output
*Note: Maximum output signal voltage approaches power supply voltage.
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"
Copyright © Parallax Inc. 4-Directional Tilt Sensor (#28036) v1.0 12/20/2010 Page 4 of 4
PUB Main
dira[0..1]~ ' Set pins 0-1 to input
pst.Start(115_200) ' Set Parallax Serial Terminal to 115,200 baud
repeat
pst.Home
pst.str(string("Phototransistor 1: "))
pst.bin(ina[0], 1)
pst.NewLine
pst.str(string("Phototransistor 2: "))
pst.bin(ina[1], 1)
waitcnt(clkfreq/10 + cnt)

Navigation menu