Your Turn: All Together Now
You can combine the xy calculated angle from Measuring Rotation Angles with the z angle introduced here to get a complete picture of how the micro:bit is oriented in space.

Example script: z_axis_and_xy_axis_angles_your_turn
- Enter, name, and save z_axis_and_xy_axis_angles_your_turn.
- Click the Send to micro:bit button.
# z_axis_and_xy_axis_angles_your_turn
from microbit import *
import math
sleep(1000)
while True:
x = accelerometer.get_x()
y = accelerometer.get_y()
z = accelerometer.get_z()
xy_angle = round( math.degrees( math.atan2(y, x) ) )
if z > 1024:
z = 1024
elif z < -1024:
z = -1024
z_angle = round( math.degrees( math.acos( z/1024) ) )
print("z_angle =", z_angle)
print("xy_angle =", xy_angle)
print()
sleep(750)
- Check the results in the serial monitor, and try each orientation shown in the pictures above.
- How close can you get to the angles shown in the pictures’ terminal?