20
CY8CKIT-003 PSoC 3 FirstTouch Starter Kit Guide, Spec. # 001-49613 Rev. *B
Example Projects
4.2.1
How the Bubble Level Emulator Project Works
A bubble level displays the amount the level deviates from horizontal using a bubble of air in a glass
via level. In this project, a level is emulated by the accelerometer on the board.
In the case of the bubble level detection, LEDs display the tilt of the board along its length
(corresponding to the X axis of the accelerometer).
The accelerometer is always under the influence of gravity. When the board is placed flat on the
ground, the static acceleration due to gravity along the X axis of the accelerometer is zero. In this
position of the board, the two LEDs in the center of the LED display are turned on. As the board is
tilted in one direction, the force of gravity along that axis increases. This increases the static
acceleration detected by the accelerometer. The X axis voltage output of the accelerometer is fed
into an ADC in the PSoC. The ADC converts this voltage into digital count, which is the measure of
the static acceleration detected by the accelerometer. PSoC determines the tilt of the board and
lights up LEDs indicating the tilt. If the board is further tilted in one direction, the LED accordingly
keeps moving to the extreme of the LED display.
Figure 4-10. Bubble Level Emulator Project Flowchart
Boot
Start
Get ADC count(V) for
Accelerometer X axis
voltage
Calculate the LED
offset for current value
of V
Update LED display
electronic components distributor