BMP180のライブラリの使用例

Dependencies:   BMP180 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "BMP180.h"
00003 
00004 #define PIN_SDA p28
00005 #define PIN_SDL p27
00006 Serial pc(USBTX,USBRX,921600);
00007 
00008 int main(){
00009     BMP180 bmp180(PIN_SDA,PIN_SDL);
00010     float pressure,temperature;
00011     printf("\rstart!\n\r");
00012     bmp180.Initialize(27,BMP180_OSS_ULTRA_LOW_POWER);//27は府大の海抜高度
00013     printf("initialization complete!\n\r");
00014     
00015     for(int i=0;i<100;i++){
00016         if(bmp180.ReadData(&temperature,&pressure)){
00017             printf("%3d:Pressure(hPa)\t:%.2f\n\r",i,pressure);
00018             printf("%3d:Temperature(C)\t:%.2f\n\r",i,temperature);
00019             printf("--------------------------------\n\r");
00020             wait(1);
00021         }
00022     }
00023     
00024     printf("complete!\n\r");
00025     
00026     return 0;
00027 }