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

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 116 · Smart Sensors and Applications
' Smart Sensors and Applications - Ch3Proj1.bs2
' Based on VertWheelRotation.bs2, this device counts the number
' of times the board has been rotated on the vertical plane.
'{$STAMP BS2}
'{$PBASIC 2.5}
angle
angleOld
x
y
turnCount
PAUSE 250
SEROUT 14, 84, [22, 12]
PAUSE 5
SEROUT 14, 84, [128, DEC5 turnCount]
DO
LOOP
PULSIN 6, 1, x
PULSIN 7, 1, y
x = (x MIN 1875 MAX 3125) - 1875 ** 13369 - 127
y = (y MIN 1875 MAX 3125) - 1875 ** 13369 - 127
angle = x ATN y
angle = angle */ 361
IF (angle >= 90 AND angle < 180) AND (angleOld < 90 OR angleOld >= 270) THEN
ENDIF
IF angle >= 270 AND (angleOld >= 90 AND angleOld < 180) THEN
ENDIF
SEROUT 14, 84, [128, DEC5 (turnCount / 2)]
P1. Example solution:
turnCount = turnCount + 1
angleOld = angle
turnCount = turnCount + 1
angleOld = angle
VAR
VAR
VAR
VAR
VAR
Word
Word
Word
Word
Word
' Initialize LCD

Related parts for 122-28029