28029 Parallax Inc, 28029 Datasheet - Page 205

KIT PARTS SMART SENSORS W/TEXT

28029

Manufacturer Part Number
28029
Description
KIT PARTS SMART SENSORS W/TEXT
Manufacturer
Parallax Inc
Datasheet

Specifications of 28029

Accessory Type
Parts Kit
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
BASIC Stamp® or Javelin Modules
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Other names
28029PAR
How BubbleGraph.bs2 Works
The first thing the Main Routine does is display the background character at the current
cursor position. With a 50 ms pause, it completes the “off” portion of a blinking asterisk.
Next, the program acquires the x and y tilt.
The program needs to scale and offset the x and y-axis tilt measurements so that the
asterisk is correctly placed in the Debug Terminal.
introduced in Chapter 3, Activity #3 works for this task.
accelerometer’s pulse values of 1875 to 3125 have to be scaled to asterisk placements of
0 to 20. By subtracting 1875 from the accelerometer measurement before scaling, we
have an input scale of 0 to 1250 (1251 elements) and an output scale of 0 to 20 (21
elements). The equation for calculating the
Substituting the number of elements in the input and output scales gives us a
constant of 1101.
A similar process results in a
code for scale and offset for both axes is:
ScaleConstant = Int[65536(output scale elements)/(input scale elements - 1)]
ScaleConstant = Int[65536(21/(1251-1))]
ScaleConstant = Int[65536(21/1250)]
ScaleConstant = Int[1101.0048]
ScaleConstant = 1101
' Replace asterisk with background character.
index = (22 * y) + x + 1
READ index, char
DEBUG CRSRXY, x, y, char
PAUSE 50
' Measure tilt.
PULSIN 6, 1, x
PULSIN 7, 1, y
' Calculate cursor position.
x = (x MIN 1875 MAX 3125) - 1875 ** 1101
y = (y MIN 1875 MAX 3125) - 1875 ** 576
y = 10 - y
**
scale constant of 576 for the y-axis, and the resulting
**
Chapter 5: Accelerometer Gaming Basics · Page 193
scale constant is:
' Coordinates -> EEPROM address
' Get background character
' Display background character
' Pause for blink effect
' Get Ax and Ay
The same scaling and offset
' Calculate x position
' Calculate y position
For the x-axis, the
**
scale

Related parts for 28029