Professional Documents
Culture Documents
$)(
!"#$%&
!"#$%#& () *+,-#".,%) /0 1$.2$+,$
|u9j S-Axis uyioscope Sensoi Nouule
0niveisity of Tasmania 2
!"#$"%#&
In this unit, you will leain about S-Axis uyioscope Sensoi mouule (one of input
mouules).
The S-Axis uyioscope Sensoi mouule is connecteu to Aiuu-ez boaiu. I2C
communication is useu to connect the S-Axis uyioscope Sensoi mouule.
Theiefoie, we neeu to use the auuiess of the mouule insteau of pin numbei to
connect the mouule to Aiuu-ez boaiu. The auuiess of the S-Axis uyioscope
Sensoi mouule is fixeu in the libiaiy (1uS).
($)*%+, -,*$.# /,)#
0$#)#1%+#) 2*+.3%,+4 %+ 5%6$7$8
void begin(int Addr);
Set the auuiessmoue (input) anu initialize the S-Axis uyioscope Sensoi mouule.
- !"#"$%&%# :
!""# ! !" $% &'%( !" '%! !""#$%% '( !-!"#$ &'() *+,$)( !"#$%& - 105
!"#$!% !"#$% : none
int readXValue();
Retuin the X Axis uyioscope value.
- !"#"$%&%#: none
- !"#$!% '()$": X Axis Gyroscope value
int readYValue();
Retuin the Y Axis uyioscope value.
- !"#"$%&%#: none
- !"#$!% '()$": Y Axis Gyroscope value
int readZValue();
Retuin the Z Axis uyioscope value.
- !"#"$%&%#: none
- !"#$!% '()$": Z Axis Gyroscope value
|u9j S-Axis uyioscope Sensoi Nouule
0niveisity of Tasmania S
-79:;# /,)#4
The sample coue will ietuin the S-Axis uyioscope values on the seiial monitoi.
/* ThreeAsixGyro.h */
/* ===== ThreeAsixGyro Method =====
void begin(uint8_t addr);
int readXValue();
int readYValue();
int readZValue();
================================== */
#include "ThreeAsixGyro.h"
#define GYRO_ADDR 105
ThreeAsixGyro gyro;
void setup() {
gyro.begin(GYRO_ADDR);
Serial.begin(9600);
}
void loop() {
Serial.print("x : ");
Serial.print(gyro.readXValue());
Serial.print("\t\ty : ");
Serial.print(gyro.readYValue());
Serial.print("\t\tz : ");
Serial.println(gyro.readZValue());
delay(1000);
}
|u9j S-Axis uyioscope Sensoi Nouule
0niveisity of Tasmania 4
!*3:*3
veiify anu uploau the coues, then it will give an output in the Seiial Nonitoi like
below: