This example displays the tilt values in the console.
The Move Hub returns the x and y values and the Technic Hub returns the x, y and z values.
By calling the poweredUpStart procedure Wheel will register tilt and acceleration values in
the global poweredUpDevices variable.
This demo only works on a real device, the simulator does not support changing tilt or acceleration values.
"Powered Up tilt sensor example" "lib/modules/standard.whl" "lib/modules/poweredUp.whl" proc main() ; Start reading the Powered Up sensors... poweredUpStart() number x, lastX number y, lastY number z, lastZ repeat ; Get the values... x = poweredUpDevices.layer1.tilt.x y = poweredUpDevices.layer1.tilt.y z = poweredUpDevices.layer1.tilt.z ; Check if one of the values is changed: if (x != lastX) or (y != lastY) or (z != lastZ) ; Display the last values: clearConsole(); printS("Tilt:") printS("x:") printN(x) printS("y:") printN(y) printS("z:") printN(z) lastX = x lastY = y lastZ = z end end end