11

Dependencies:   mbed C12832 MMA7660

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "C12832.h"
00003 #include "MMA7660.h"
00004 
00005 // Using Arduino pin notation
00006 C12832 lcd(D11, D13, D12, D7, D10);
00007 MMA7660 MMA(I2C_SDA,I2C_SCL);
00008 enum Orientation {Up, Down,
00009                   Right, Left,
00010                   Back, Front,
00011                   Unknown
00012                  };
00013 
00014 int main()
00015 {
00016     lcd.cls();
00017     lcd.locate(0,3);
00018     // lcd.printf("mbed application shield!");
00019 
00020     while(1) {
00021         lcd.locate(60,0);
00022         lcd.printf("x=%.2f",MMA.x());
00023         lcd.locate(60,8);
00024         lcd.printf("y=%.2f",MMA.y());
00025         lcd.locate(60,16);
00026         lcd.printf("z=%.2f",MMA.z());
00027         lcd.locate(0,8);
00028         if (MMA.getSide()==Front) lcd.printf("Front");
00029         else if (MMA.getSide()==Back) lcd.printf("Back");
00030         lcd.locate(0,16);
00031         switch (MMA.getOrientation()) {
00032             case Left :
00033                 lcd.printf("Left");
00034                 break;
00035             case Right :
00036                 lcd.printf("Right");
00037                 break;
00038             case Up :
00039                 lcd.printf("     ");lcd.locate(0,16);
00040                 lcd.printf("Up");
00041                 break;
00042             case Down :
00043                 lcd.printf("Down");
00044                 break;
00045         }
00046 
00047         wait(0.2);
00048     }
00049 }