Rotation

Find how much the Calliope mini is tilted in different directions.

input.rotation(Rotation.Roll);

The Calliope mini has a part called the accelerometer that can check how the Calliope mini is moving.

Parameters

Returns

Example: Calliope mini leveler

This program helps you move the Calliope mini until it is level. When it is level, the Calliope mini shows a smiley.

If you are running this program in a browser, you can tilt the Calliope mini with your mouse.

let pitch = 0;
basic.forever(() => {
    pitch = input.rotation(Rotation.Pitch);
    let roll = input.rotation(Rotation.Roll);
    if (Math.abs(pitch) < 10 && Math.abs(roll) < 10) {
        basic.showLeds(`
            . # . # .
            . . . . .
            . . . . .
            # . . . #
            . # # # .
            `);
    } else {
        basic.showLeds(`
            # . . . #
            . # . # .
            . . # . .
            . # . # .
            # . . . #
            `);
        }
    });

See also

acceleration, compass-heading

Edit this page on GitHub