Created
February 25, 2020 23:09
-
-
Save ShawnHymel/4d2ed5b5e8f6b516d1c5f7e52d40bf68 to your computer and use it in GitHub Desktop.
Low Cost Arduino DAQ Example
This file contains hidden or 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
| #include <Wire.h> | |
| #include <Adafruit_MSA301.h> | |
| #include <Adafruit_Sensor.h> | |
| Adafruit_MSA301 msa; | |
| void setup() { | |
| // Open serial port | |
| Serial.begin(250000); | |
| // Initialize MSA301 | |
| if (!msa.begin()) { | |
| Serial.println("Error: Could not find MSA301 chip"); | |
| while (1); | |
| } | |
| } | |
| void loop() { | |
| char c; | |
| // Wait until we get an 'r' on the serial line | |
| if (Serial.available()) { | |
| c = Serial.read(); | |
| if (c == 'r') { | |
| // Get new MSA reading | |
| msa.read(); | |
| // Print out results | |
| Serial.print(msa.x_g); | |
| Serial.print('\t'); | |
| Serial.print(msa.y_g); | |
| Serial.print('\t'); | |
| Serial.println(msa.z_g); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment