Schematic WITH THE Arduino can Judging the image below:
Schematic with arduino |
Coding :
// Free Tutorial Arduino // www.ioisalman.com /* Memsic2125 * Pin-pin Address * X output of accelerometer to digital pin 2 * Y output of accelerometer to digital pin 3 * +V of accelerometer to +5V * GND of accelerometer to ground */ const int xPin = 2; // X output of the accelerometer const int yPin = 3; // Y output of the accelerometer void setup() { Serial.begin(9600); pinMode(xPin, INPUT); pinMode(yPin, INPUT); } void loop() { int pulseX, pulseY; int accelerationX, accelerationY; pulseX = pulseIn(xPin, HIGH); pulseY = pulseIn(yPin, HIGH); accelerationX = ((pulseX / 10) - 500) * 8; accelerationY = ((pulseY / 10) - 500) * 8; Serial.print(accelerationX); Serial.print("\t"); Serial.print(accelerationY); Serial.println(); delay(100); }
0 Response to "Measuring Acceleration, Tilt, Rotation and Vibration with Arduino"
Post a Comment