Freescale MMA8451Q Accelerometer


has experience of using 1 of these?

i bought http://www.ebay.co.uk/itm/freescale-mma8451q-3-axis-accelerometer-i2c-arduino-/270861537789?pt=lh_defaultdomain_3&hash=item3f109b11fd#ht_730wt_986 , code @ bottom of page i've posted below. dont understand it. need advice on knowing pins attach on board?

thanks in advance...

code: [select]
#include i2c.h
//i2c.h available at:
//http://www.dsscircuits.com/articles/arduino-i2c-master-library.html //or directly...
//http://dsscircuits.com/images/code/i2c_rev2.zip

#define acc 0x1d

void setup() {
   i2c.begin();
   serial.begin(9600);
}

void loop() {
   //uncomment required start of /*who - ask device id default: 0x58*/
   //i2c.read(acc,0x0d,1) ;
   //who //serial.print("i am:");
   //byte = i2c.receive();
   //serial.print(who,bin);
   //serial.print(" ");
   //serial.println(who, dec);
   /*cntrl reg 1 - tell if active bit has been set or not*/
   //i2c.read(acc,0x2a,1) ;
   //serial.print("ctrl reg 1: ");
   //serial.println(i2c.receive(), bin);
   /*system mode 00 - sleep 01 - awake 10 - standby */
   i2c.read(acc,0x0b,1) ;
   //
   //serial.print("sys mode:");
   //serial.println(i2c.receive(), bin);
   if(i2c.receive() == 0x00) {
     serial.print("waking device");
     i2c.write(acc,0x2a,0x01);
   }
   else if(i2c.receive() == 0x01) {
     serial.print("awake\n");
   }
   else if(i2c.receive() == 0x02) {
     serial.print("standby\n");
   }
 
   /*x register*/
   i2c.read(acc,0x01,1);
   byte x1 = i2c.receive();
   serial.print("x1:");
   serial.println(x1, dec);
   
   /*y register*/
   i2c.read(acc,0x03,1);
   byte y1 = i2c.receive();
   serial.print("y1:");
   serial.println(y1, dec);
   
   /*z registers*/
   i2c.read(acc,0x05,1);
   byte z1 = i2c.receive();
   serial.print("z1:");
   serial.println(z1, dec);
   delay(100);
   
//not necessary can see info

haven't used i2c here arduino library reference

http://www.arduino.cc/en/reference/wire

it says bit i2c pins, in arduino hardware section board, there description of each boards secondary pin functions ( interrupt, pwm ). should describe i2c pins

your accelerometer board should have scl, sda markers on underneath next pins refer to.


Arduino Forum > Using Arduino > Project Guidance > Freescale MMA8451Q Accelerometer


arduino

Comments

Popular posts from this blog

Joomla site hacked, cant see front and - Joomla! Forum - community, help and support

Christian Home School Programs - Joomla! Forum - community, help and support

Trouble with PF_OutFlag_I_USE_AUDIO and PF_CHECKOUT_LAYER_AUDIO