センサーをつかう

// ジャイロを2、加速度を3、コンパスを4に接続してください。

#include "NXCDefs.h"

task main() {

//compass
  SetSensorLowspeed(IN_4);
  int compass;

//accel
  SetSensorLowspeed(IN_3);
  int x,y,z;
  bool bVal;

//gyro
  SetSensorHTGyro(IN_2);
  int gyro;

  while(true){
    compass = SensorHTCompass(IN_4);
    TextOut(0,60,"compass",true);
    NumOut(60,60, compass);

    bVal = ReadSensorHTAccel(IN_3, x, y, z);
    TextOut(0,35,"accel x y z",false);
    if (bVal){
      NumOut( 0, 40, x);
      NumOut(30, 40, y);
      NumOut(60, 40, z);
    } else {
    }
  
    gyro = SensorHTGyro(IN_2, 0);
    NumOut( 0, 20, gyro);
    TextOut(0,15,"gyro",false);

    Wait(80);
  }
}
Last modified: 2014-09-01 Attached files total: 33MB