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
.
Manipulate[
{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:
Manipulate[
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:
Manipulate[
x,
{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.