Another toy I ordered quite awhile ago was an accelerometer. Just hooked it up, no sweat. Here's the code:
#define xPin 5
#define yPin 4
#define zPin 3
int x = 0;
int y = 0;
int z = 0;
int delta = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
delta = x + y + z;
x = analogRead(xPin);
y = analogRead(yPin);
z = analogRead(zPin);
delta -= x + y + z;
Serial.print(x);
Serial.print(", ");
Serial.print(y);
Serial.print(", ");
Serial.print(z);
Serial.print(", ");
Serial.println(abs(delta));
delay(500);
}
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVF6FJ48hpZRuBVYMRdZ-L6jf2xcqwNjswsAGTR-d0TOfj4QFH_ztzm-l1CCk2x4wJr3yRbWxoyE9U4UsI5B4FHV3fFmGEyUxTX8nAHZSMgTNa8EftVinUjemTO4i2IkbePRtSvknwKVo/s320/img_0002.jpg)