Avatar for user116256

user116256

Member since Aug 2020 • Last active Aug 2020
  • 1 conversations
  • 1 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user116256

    Hello everyone,
    I'm trying to work with the accelerometer/gyroscope in the puck.js v2.

    I wrote a small script to transmitt accelerometer data over bluetooth as follows:

    var running = false;
    
    function accelHandlerTrigger(data) {
      console.log(data);
      var d = [
        "A",
        Math.round(data.acc.x),
        Math.round(data.acc.y),
        Math.round(data.acc.z)
      ];
      Bluetooth.println(d.join(","));
    }
    
    setWatch(function() {
      if (running) {
        Puck.accelOff();
        Puck.removeListener('accel', accelHandlerTrigger);
        running = false;
      } else {
        running = true;
        Puck.accelOn(52);
        Puck.on('accel', accelHandlerTrigger);
      }
    }, BTN, {repeat:true});
    

    However, the sensor measurements that I get seems to be too high. For example:

    "acc": { "x": -342, "y": 398, "z": 8270 }, 
    "gyro": { "x": 313, "y": -299, "z": -92 }
    
    "acc": { "x": -319, "y": 371, "z": 8098 }, 
    "gyro": { "x": 167, "y": -290, "z": -69 }
    

    From my understanding, the accelerometer default is ±2g and the gyroscope default is ±125 dps.

    Is this correct? or why are the values too high?

Actions