Where is up? Using the ADXL330 3-axis accelerometer

Background

Another long term project waiting for Mbed as a development tool. Previously limited by 2-axis, USB, unfathomable code, wrong resolution etc. All comes together in the ADXL330 3-axis analog output accelerometer hitched in with Mbed.

http://www.coolcomponents.co.uk/catalog/product_info.php?cPath=36&products_id=95

Since the Nokia 6610 LCD is working (thanks Simon), I really like it and use it a lot. So that's what I use here. For you retro types the TextLCD code is included. Wiring is as per the code.

Photo with Nokia

source:Where_is_up/doc/Accel.jpg

Nokia 6610 code

#include "mbed.h"
#include "MobileLCD.h"
MobileLCD lcd(p5, p6, p7, p8, p9);  //MOSI,,SCK,CS,RST
                                //BL to Vcc
AnalogIn xin(p20);
AnalogIn yin(p19);
AnalogIn zin(p18);
int main() {
    lcd.background(0x0000FF);
    lcd.cls();
    float xval;
    float yval;
    float zval;
    while(1) {
        lcd.cls();
        xval=(xin.read_v()-1.662)*3;
        lcd.locate(1,1);  lcd.printf("X=");  lcd.printf("%1.3fg",xval);
        yval=(yin.read_v()-1.662)*3;
        lcd.locate(1,3);  lcd.printf("Y=");  lcd.printf("%1.3fg",yval);
        zval=(zin.read_v()-1.622)*3;
        lcd.locate(1,5);  lcd.printf("Z=");  lcd.printf("%1.3fg",zval);
        wait_ms(100);
    }
}

TextLCD code

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(p24, p25, p26, p27, p28, p29, p30);
AnalogIn xin(p20);
AnalogIn yin(p19);
AnalogIn zin(p18);
int main() {
    float xval;
    float yval;
    float zval;
    while(1) {
        lcd.cls();
        xval=(xin.read_v()-1.662)*3;
        lcd.locate(0,0);  lcd.printf("X=");  lcd.printf("%1.3fg",xval);
        yval=(yin.read_v()-1.662)*3;
        lcd.locate(9,0);  lcd.printf("Y=");  lcd.printf("%1.3fg",yval);
        zval=(zin.read_v()-1.622)*3;
        lcd.locate(0,1);  lcd.printf("Z=");  lcd.printf("%1.3fg",zval);
        wait_ms(100);
    }
}