carlos ruiz / Mbed 2 deprecated ACELEROMETRO

Dependencies:   TextLCD3libreriatexlcd mbed

Fork of MMA8451Q by Johan Kritzinger

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MMA8451Q.h"
00003 #include "TextLCD.h"
00004 #define MMA8451_I2C_ADDRESS (0x1d<<1)
00005 
00006 TextLCD lcd(PTB10,PTB11,PTE2,PTE3,PTE4,PTE5);
00007 
00008 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
00009 
00010 float sensor_data[3];
00011 
00012 int main(){
00013     lcd.locate(0,0);
00014     lcd.printf("Tarea           Acelerometro");
00015     wait(2);
00016     lcd.cls();
00017     lcd.locate(0,0);
00018     lcd.printf("X:");
00019     lcd.locate(7,0);
00020     lcd.printf("Y:");
00021     lcd.locate(0,1);
00022     lcd.printf("Z:");
00023     while(1){
00024     
00025         acc.getAccAllAxis( &sensor_data[0]);
00026         lcd.locate(2,0);
00027         lcd.printf("   ");
00028         lcd.locate(2,0);
00029         lcd.printf("%.2f",sensor_data[2]);
00030         lcd.locate(9,0);
00031         lcd.printf("   ");
00032         lcd.locate(9,0);
00033         lcd.printf("%.2f",sensor_data[0]);
00034         lcd.locate(3,1);
00035         lcd.printf("   ");
00036         lcd.locate(3,1);
00037         lcd.printf("%.2f",sensor_data[1]);        
00038         wait(1);
00039         
00040     }
00041     
00042     
00043 }