当前位置: 首页>>代码示例>>C++>>正文


C++ MPU6050::whoami方法代码示例

本文整理汇总了C++中MPU6050::whoami方法的典型用法代码示例。如果您正苦于以下问题:C++ MPU6050::whoami方法的具体用法?C++ MPU6050::whoami怎么用?C++ MPU6050::whoami使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MPU6050的用法示例。


在下文中一共展示了MPU6050::whoami方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

void setup() {
  Serial.begin(38400);

  Serial.print("Device type:   0x");Serial.println(HW_TYPE,HEX,8);
  Serial.print("Device serial: 0x");Serial.println(HW_SERIAL,HEX,8);
  //Dump source package to serial
  int len=source_end-source_start;
  char* base=source_start;
  Serial.print("Source package length: ");
  Serial.println(len,DEC);
  Serial.print("Source package start: 0x");
  Serial.println((int)base,DEC,8);
  d.begin();
  while(len>0) {
    d.line(base,0,len>120?120:len);
    base+=120;
    len-=120;
  }
  d.end();

  Wire1.begin();
  SPI1.begin(1000000,1,1);

  bool worked=sd.begin();
  Serial.print("sd");    Serial.print(".begin ");Serial.print(worked?"Worked":"didn't work");Serial.print(". Status code ");Serial.println(sd.errnum);

  worked=p.begin(1);
  Serial.print("p");     Serial.print(".begin ");Serial.print(worked?"Worked":"didn't work");Serial.print(". Status code ");Serial.println(p.errnum);

  worked=fs.begin();  
  Serial.print("fs");    Serial.print(".begin ");Serial.print(worked?"Worked":"didn't work");Serial.print(". Status code ");Serial.println(fs.errnum);
  sector.begin();
  fs.print(Serial,sector);

  mpu6050.begin();
  Serial.print("MPU6050 identifier (should be 0x68): 0x");
  Serial.println(mpu6050.whoami(),HEX);

  hmc5883.begin();
  char HMCid[4];
  hmc5883.whoami(HMCid);
  Serial.print("HMC5883L identifier (should be 'H43'): ");
  Serial.println(HMCid);

  worked=ad799x.begin(0xB); //Turn on channels 0, 1, and 3
  Serial.print("ad799x");Serial.print(".begin ");Serial.print(worked?"Worked":"didn't work");Serial.print(". Status code ");Serial.println(0);

  worked=bmp180.begin();
  Serial.print("bmp180");Serial.print(".begin ");Serial.print(worked?"Worked":"didn't work");Serial.print(". Status code ");Serial.println(0);
  Serial.print("BMP180 identifier (should be 0x55): 0x");
  Serial.println(bmp180.whoami(),HEX);

  bmp180.printCalibration(&Serial);

}
开发者ID:kwan3217,项目名称:Loginator,代码行数:55,代码来源:main.cpp


注:本文中的MPU6050::whoami方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。