28029 Parallax Inc, 28029 Datasheet - Page 120

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
Page 108 · Smart Sensors and Applications
Example Program: HorizontalTilt.bs2
This example program displays your board's tilt in terms of degrees from horizontal.
' -----[ Title ]--------------------------------------------------------------
' Smart Sensors and Applications - HorizontalTilt.bs2
' Test arcsine for sine values from -127 to 127.
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Constants ]----------------------------------------------------------
Negative
Positive
' -----[ Variables ]----------------------------------------------------------
x
y
side
angle
sign
' -----[ Initialization ]-----------------------------------------------------
DEBUG CLS
' -----[ Main Routine ]-------------------------------------------------------
DO
PULSIN 6, 1, x
LOOP
Enter, save and run HorizontalTilt.bs2.
Compare various tilt angles to the Debug Terminal's axis display.
side = x
GOSUB Arcsine
DEBUG HOME, "x tilt angle = ", CLREOL, SDEC3 angle, CR
side = y
GOSUB Arcsine
DEBUG "y tilt angle = ", CLREOL, SDEC3 angle
PAUSE 100
CON
CON
VAR
VAR
VAR
VAR
VAR
1
0
Word
Word
Word
Word
Bit
' BASIC Stamp Directive
' PBASIC Directive
' Sign - .bit15 of Word variables
' Memsic x-axis measurement
' Memsic y-axis measurement
' trig subroutine variable
' result angle - degrees
' Sign bit
' Clear Debug Terminal
' x-axis measurement

Related parts for 28029