Skip to content

Instantly share code, notes, and snippets.

@emsk
Created November 18, 2013 14:59
Show Gist options
  • Save emsk/7529156 to your computer and use it in GitHub Desktop.
Save emsk/7529156 to your computer and use it in GitHub Desktop.
加速度データを取得してシリアルポートに出力
/*
Send z-axis acceleration.
- LilyPad Arduino USB ... https://www.sparkfun.com/products/11190
- FLORA Accelerometer (LSM303) ... http://www.adafruit.com/products/1247
*/
#include <Wire.h>
#include <LSM303.h>
LSM303 compass;
void setup() {
Serial.begin(9600);
Wire.begin();
compass.init();
compass.enableDefault();
}
void loop() {
compass.read();
Serial.println((int)compass.a.z);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment