Copyright © Parallax Inc.
Page 3 of 12
BASIC Stamp HomeWork Board
' {$STAMP BS2}
' {$PBASIC 2.5}
SDA PIN 0 ' SDA of gyro connected to P0
SCL PIN 1 ' SCL of gyro connected to P1
WRITE_Data CON $D2 ' Request Write operation
READ_Data CON $D3 ' Request Read operation
' Control registers
CTRL_REG1 CON $20
CTRL_REG2 CON $21
CTRL_REG3 CON $22
CTRL_REG4 CON $23
STATUS_REG CON $27
OUT_X_INC CON $A8
X VAR Word
Y VAR Word
Z VAR Word
rawl VAR Word
rawh VAR Word
' Variables for I2C communications
I2C_DATA VAR Byte
I2C_LSB VAR Bit
I2C_REG VAR Byte
I2C_VAL VAR Byte
PAUSE 100 ' Power up delay
' Set up data ready signal
I2C_REG = CTRL_REG3
I2C_VAL = $08