With the following code I can get the value of the "Sudden Motion Sensor", which is build into MacBooks:

Dynamic@ControllerState[{"X", "Y", "Z"}, ControllerPath -> {"Sudden Motion Sensor"}]

I want to use the values to control some variables in a Manipulate statement, however this doesn't seems to work:

Manipulate[x,"X" -> {x, -1, 1}, ControllerPath -> "Sudden Motion Sensor"]
  • $\begingroup$ off topic but do you know which apple laptops have SMS? a macbook I had did have an SMS, my current air does not seem to have one (or at least I cannot see any indication via pmset, mathematica does not find it etc). this despite not finding any info anywhere about it not being included in SSD notebooks. $\endgroup$
    – acl
    Feb 20, 2013 at 20:08
  • $\begingroup$ @acl It would only make sense to have in MacBooks with a HDD for its original purpose, but i don't know. $\endgroup$
    – Tyilo
    Feb 20, 2013 at 20:13
  • 1
    $\begingroup$ @acl Here it is: support.apple.com/kb/HT1935, only HDD MacBooks have it. $\endgroup$
    – Tyilo
    Feb 20, 2013 at 20:14
  • $\begingroup$ Thanks, I read "All Intel-based Mac notebooks have Sudden Motion Sensor technology" and somehow skipped over "Computers with Solid State Drives (SSD) or Flash Storage do not use SMS"... $\endgroup$
    – acl
    Feb 20, 2013 at 20:15
  • $\begingroup$ For what is worth: I have a 2013 MBP retina with SSD and it does have a motion sensor. $\endgroup$
    – Ziofil
    Nov 11, 2014 at 1:26

1 Answer 1


One can set variables equal to the controller values like below. They can then be used in a computation. Here I just scaled them by a.

 {x0, y0, z0} = ControllerState[{"X", "Y", "Z"}, ControllerPath -> {"Sudden Motion Sensor"}];
 a {x0, y0, z0},
 {a, 1, 100}

Controlling the view point of 3D graphics could be fun, except that it's rather shaky on my computer. Here the ViewVector is determined by the controller values, and a changes the plot:

 Plot3D[x^2 + a y^2, {x, -1, 1}, {y, -1, 1}, 
  ViewVector -> Dynamic[{-5 Normalize@ControllerState[{"X", "Y", "Z"}, 
        ControllerPath -> {"Sudden Motion Sensor"}], {0, 0, 0.5 + a/2}}],
  SphericalRegion -> True],
 {a, 0.5, 2}

But I find my SMS rather noisy and in need of smoothing. Also my "Y" coordinate seems to take on only two values, plus or minus 0.0039.

Or perhaps one would like to see a slider:

 {x, -1, 1,
    Slider[Dynamic[x, x = ControllerState["X", ControllerPath -> {"Sudden Motion Sensor"}]], {-1, 1}] &}

However, the Dynamic inside Slider overrides the usual action of the Slider. It basically just displays its position according to the sensor's x value.

  • $\begingroup$ That doesn't directly modify a. Isn't it possible to do that? $\endgroup$
    – Tyilo
    Feb 20, 2013 at 20:55
  • $\begingroup$ @Tyllo Do you want a set equal to one of the SMS coordinates, or some function of them? $\endgroup$
    – Michael E2
    Feb 20, 2013 at 20:56
  • $\begingroup$ Nevermind, it works perfectly. $\endgroup$
    – Tyilo
    Feb 20, 2013 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.