pxt-calliope/docs/lessons/zoomer/challenges.md
2016-06-14 17:28:08 -04:00

956 B

zoomer blocks challenges

Coding challenges for zoomer.

Before we get started

Complete the following activity and your finished code should look like this:

basic.forever(() => {
    let az = input.acceleration(Dimension.Z)
    basic.showNumber(az)
})

Challenge 1

We'll modify the code to display the x acceleration if the A button is pressed. For that, we need to store acceleration (x) in a new variable ax and use a button (A) is pressed to detect if the button is pressed.

basic.forever(() => {
    let az = input.acceleration(Dimension.Z)
    let ax = input.acceleration(Dimension.X)
    if (input.buttonIsPressed(Button.A)) {
        basic.showNumber(ax)
    }
    basic.showNumber(az)
})
  • Run the code to see if it works as expected.

Challenge 2

Display the y acceleration when B is pressed by adding another if statement using button (B) is pressed.