-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <BMA400.h> | ||
#include <Wire.h> | ||
|
||
BMA400 bma400; | ||
|
||
void setup() | ||
{ | ||
// put your setup code here, to run once: | ||
Serial.begin(115200); | ||
|
||
Wire.begin(GPIO_NUM_21, GPIO_NUM_22, 400000); | ||
|
||
if (bma400.Initialize(BMA400_ADDRESS_PRIMARY)) // Using the default Wire interface | ||
{ | ||
printf("BMA400 Sensor successfully found\r\n"); | ||
bma400.Setup( | ||
BMA400::power_mode_t::LOW_POWER, | ||
BMA400::output_data_rate_t::Filter2_100Hz, | ||
BMA400::acceleation_range_t::RANGE_4G); | ||
} | ||
else | ||
printf("Error! no BMA400 sensor found\r\n"); | ||
} | ||
|
||
void loop() | ||
{ | ||
// put your main code here, to run repeatedly: | ||
float acceleration[3] = {0}; | ||
bma400.ReadAcceleration(acceleration); | ||
printf("Acceleration(g) [X, Y, Z] = %2.2f %2.2f %2.2f\r\n", acceleration[0], acceleration[1], acceleration[2]); | ||
delay(1000); | ||
} |
32 changes: 32 additions & 0 deletions
32
examples/BasicAutoAddressDetect/BasicAutoAddressDetect.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <Arduino.h> | ||
#include <BMA400.h> | ||
#include <Wire.h> | ||
|
||
BMA400 bma400; | ||
void setup() | ||
{ | ||
// put your setup code here, to run once: | ||
Serial.begin(115200); | ||
|
||
Wire.begin(GPIO_NUM_21, GPIO_NUM_22, 400000); | ||
|
||
if (bma400.Initialize()) // Automatically resolving the address | ||
{ | ||
printf("BMA400 Sensor successfully found\r\n"); | ||
bma400.Setup( | ||
BMA400::power_mode_t::NORMAL, | ||
BMA400::output_data_rate_t::Filter1_048x_200Hz, | ||
BMA400::acceleation_range_t::RANGE_4G); | ||
} | ||
else | ||
printf("Error! no BMA400 sensor found\r\n"); | ||
} | ||
|
||
void loop() | ||
{ | ||
// put your main code here, to run repeatedly: | ||
float acceleration[3] = {0}; | ||
bma400.ReadAcceleration(acceleration); | ||
printf("Acceleration(g) [X, Y, Z] = %2.2f %2.2f %2.2f\r\n", acceleration[0], acceleration[1], acceleration[2]); | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <Arduino.h> | ||
#include <BMA400.h> | ||
#include <Wire.h> | ||
|
||
BMA400 bma400; | ||
void setup() | ||
{ | ||
// put your setup code here, to run once: | ||
Serial.begin(115200); | ||
|
||
Wire1.begin(GPIO_NUM_21, GPIO_NUM_22, 400000); | ||
|
||
if (bma400.Initialize(Wire1)) // Using user defined (Wire1) interface & automatically resolving the address | ||
{ | ||
printf("BMA400 Sensor successfully found\r\n"); | ||
bma400.Setup( | ||
BMA400::power_mode_t::NORMAL, | ||
BMA400::output_data_rate_t::Filter1_048x_200Hz, | ||
BMA400::acceleation_range_t::RANGE_4G); | ||
} | ||
else | ||
printf("Error! no BMA400 sensor found\r\n"); | ||
} | ||
|
||
void loop() | ||
{ | ||
// put your main code here, to run repeatedly: | ||
float acceleration[3] = {0}; | ||
bma400.ReadAcceleration(acceleration); | ||
printf("Acceleration(g) [X, Y, Z] = %2.2f %2.2f %2.2f\r\n", acceleration[0], acceleration[1], acceleration[2]); | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters