pxt-calliope/docs/lessons/zoomer/challenges.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

954 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.