SPI and I2C interfaces, displaying accelerometer data on the LCD

Dependencies:   mbed C12832 MMA7660

main.cpp

Committer:
kaushalpkk
Date:
2019-03-21
Revision:
4:14963dcf2861
Parent:
3:2db94ee076ee

File content as of revision 4:14963dcf2861:

//mbed library
#include "mbed.h"
//lcd library
#include "C12832.h"
//accelerometer library
#include "MMA7660.h"

//init LCD
C12832 lcd(p5, p7, p6, p8, p11);
// init accel
MMA7660 MMA(p28, p27);

int main()
{
    lcd.cls();
    lcd.locate(0,3);
    lcd.printf("mbed application board!");
    wait(5);
    if (MMA.testConnection()) {
        lcd.printf("the accelerometer is working OK");
        wait(5);
    }
    while(true) {
        lcd.locate(0,3);
        lcd.printf("     X        Y       Z   \n");
        lcd.locate(0,15);
        lcd.printf("%.3f   %.3f  %.3f  \r", MMA.x(), MMA.y(), MMA.z());
        wait(1);
        lcd.cls();
    }
}