122-28029 Parallax Inc, 122-28029 Datasheet - Page 120

GUIDE STUDENT SMART SENSORS

122-28029

Manufacturer Part Number
122-28029
Description
GUIDE STUDENT SMART SENSORS
Manufacturer
Parallax Inc
Datasheet

Specifications of 122-28029

Accessory Type
Manual
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
Smart Sensors
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
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 122-28029