Example using sensors from the mbed apps board or shield

Dependencies:   C027 LM75B MMA7660 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "C027.h"
00003 #include "C12832_lcd.h"
00004 #include "LM75B.h"
00005 #include "MMA7660.h"
00006 
00007 //#define MBED_APPS_SHIELD
00008 #define MBED_APPS_BOARD
00009 
00010 #if defined(MBED_APPS_SHIELD)
00011   C12832_LCD lcd(D11, D13, D12, D7, D10);
00012   DigitalOut myled(P3_25);
00013   LM75B temperature_sensor(SDA, SCL);
00014   MMA7660 mma(SDA, SCL);
00015 #elif defined(MBED_APPS_BOARD)
00016   C12832_LCD lcd(p5, p7, p6, p8, p11);
00017   DigitalOut myled(LED1);
00018   LM75B temperature_sensor(p28, p27);
00019   MMA7660 mma(p28, p27);
00020 #else
00021 #error application board not defined
00022 #endif
00023 
00024 int main() {
00025     lcd.cls();
00026     lcd.locate(0,3);
00027     lcd.printf("Sensor Lab\n");
00028     while(1) {
00029         myled = 1;
00030         wait(0.2);
00031         myled = 0;
00032         wait(0.2);
00033         float temperature = temperature_sensor;
00034         float x = mma.x();
00035         float y = mma.y();
00036         float z = mma.z();
00037     }
00038 }