Leonardo Restrepo / Mbed 2 deprecated Acelerometro

Dependencies:   MMA8451Q TextLCD mbed

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 
00007 
00008 
00009 
00010 TextLCD lcd(PTB10,PTB11,PTE2,PTE3,PTE4,PTE5);
00011 
00012 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
00013 
00014 float sensor_data[3];
00015 
00016 int main(){
00017     lcd.locate(0,0);
00018     lcd.printf("Tarea Acelerometro");
00019     wait(2);
00020     lcd.cls();
00021     lcd.locate(0,0);
00022     lcd.printf("X:");
00023     lcd.locate(7,0);
00024     lcd.printf("Y:");
00025     lcd.locate(3,1);
00026     lcd.printf("Z:");
00027     while(1){
00028     
00029         acc.getAccAllAxis( &sensor_data[0]);
00030         lcd.locate(2,0);
00031         lcd.printf("   ");
00032         lcd.locate(2,0);
00033         lcd.printf("%.2f",sensor_data[2]);
00034         lcd.locate(9,0);
00035         lcd.printf("   ");
00036         lcd.locate(9,0);
00037         lcd.printf("%.2f",sensor_data[0]);
00038         lcd.locate(5,1);
00039         lcd.printf("   ");
00040         lcd.locate(5,1);
00041         lcd.printf("%.2f",sensor_data[1]);        
00042         wait(1);
00043         
00044     }
00045     
00046     
00047 }