Skip to content

Instantly share code, notes, and snippets.

@ShawnHymel
Created February 25, 2020 23:09
Show Gist options
  • Save ShawnHymel/4d2ed5b5e8f6b516d1c5f7e52d40bf68 to your computer and use it in GitHub Desktop.
Save ShawnHymel/4d2ed5b5e8f6b516d1c5f7e52d40bf68 to your computer and use it in GitHub Desktop.
Low Cost Arduino DAQ Example
#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);
}
}
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment