Accelerometer, ADXL335
The ADXL335 accelerometer on its GY-61 breakout: one analog voltage per axis, no bus and no library. Aliases: GY-61, analog accelerometer.
The analog accelerometer of the tilt-controlled games: three analogRead() calls and
some arithmetic.
Pins
| Pin | What it does |
|---|---|
VCC |
Supply, 3 V to 5 V. The board's regulator gives the chip 3.3 V. |
X |
The X axis, as a voltage. |
Y |
The Y axis. |
Z |
The Z axis. |
GND |
Ground. |
Properties
tilt_x and tilt_y are the tilts it starts with, in degrees, -90 to 90.
While it runs
The two sliders tilt the board about its two flat axes. Flat on the table, X and Y read 0 g and Z reads 1 g.
What the model gets right
From the ADXL335 datasheet:
Ratiometric outputs. At 0 g each output sits at half the chip's supply, and 1 g moves it by a tenth of the supply: 300 mV/g at the datasheet's 3 V, and 330 mV/g on the GY-61's 3.3 V. So on a 5 V Uno, 0 g is about 338 counts and 1 g about 68 counts either side.
Gravity. The part is still, so gravity is the only acceleration: tilted, it moves from Z onto X and Y, and the three never add up to more than 1 g.
The output resistance. Each output leaves the chip through 32 kohm, which is what
analogRead() sees.
What it does not model
Shakes, bumps and falls; the chip-to-chip spread of the zero-g level (calibrate a real one flat on the table); noise; and the self-test pin, which the GY-61 does not bring out.
Common mistakes
Taking 512 as 0 g. On a 5 V board with this module, 0 g is 1.65 V, about 338 counts.
Powering the bare chip from 5 V. The GY-61's regulator is what makes that safe.
See it in action
Tilt maze rolls a dot around an 8x8 LED matrix as the board tilts. Open it at /templates.