11 years, 1 month ago.

How to read data from accelerometer MMA8452Q using i2c

Hi,

I have connected the SDA & SCL to the p28 & p27 respectively to the mbed board (LPC 1768). Can you please tell me how to read the data from SDA line. I am trying to read the data and display it on text LCD. Below is my code

  1. include "mbed.h"
  2. include"TextLCD.h"
  3. include"i2c.h"

TextLCD lcd(p11, p12, p13, p14, p15, p16, TextLCD::LCD16x2); rs, e, d4-d7

I2C i2c(p28, p27);

int main() {

int addr = 0x2A; device address of my accelerometer char read[2]; while(1) {

lcd.printf("data=%d",i2c.read(addr, read, 2)); wait(5); } }

Question relating to:

A library to read data from the Triple Axis Accelerometer Breakout - MMA8452Q from Sparkfun.

This problem is solved.

posted by Akshay Padegaonkar 19 Jul 2014
Be the first to answer this question.