Accel-only breakout board (working)

By: paul

2010-06-13 10:10:39

Boards from Laen's PCB group order arrived today, and I'm happy to say the Accel-only breakout board works. This was inspired by Sott's design, but with support for 5 volts, and using I2C. I'll have 4 more kits at the next Monday meetup. The kit has all parts except the MMA7455 chip, and the kit's FREE if you build it or wreck it trying. So far, I've only written a tiny test program. Here's the code:
#include <Wire.h>


void setup() {
  Serial.begin(38400);
  Wire.begin();
  delay(500);
  
  // enter measurement mode
  Wire.beginTransmission(29);
  Wire.send(22);
  Wire.send(5);
  Wire.endTransmission();
}

void loop() {
  signed char x, y, z;
  
  delay(100);
  Wire.beginTransmission(29);
  Wire.send(6);
  Wire.endTransmission();
  Wire.requestFrom(29, 3);
  while (!Wire.available()) /* wait */ ;
  x =  Wire.receive();
  while (!Wire.available()) /* wait */ ;
  y =  Wire.receive();
  while (!Wire.available()) /* wait */ ;
  z =  Wire.receive();
  
  Serial.print("x = ");
  Serial.print((int)x);
  Serial.print(", y = ");
  Serial.print((int)y);
  Serial.print(", z = ");
  Serial.print((int)z);
  Serial.println();
  delay(200);
  
}

Obviously there's quite a lot more that can be done with the code, but at least this prints raw numbers and they clearly do change if you move the board around, or tilt it on axis. Clearly quite a lot more software work is needed to turn the raw acceleration numbers into useful X, Y, Z displacement and/or tilt angles.
Back to archive index