Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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
- include "mbed.h"
- include"TextLCD.h"
- 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:

This problem is solved.
posted by Akshay Padegaonkar 19 Jul 2014