2016-03-25 16:47:20 -07:00
# glowing pendulum quiz answers
2016-04-01 16:22:47 -07:00
construct a pendulum that glows using acceleration.
2016-03-25 16:47:20 -07:00
## Name
## Directions
2016-04-15 15:02:26 -07:00
Use this activity document to guide your work in the [glowing pendulum activity ](/lessons/glowing-pendulum/activity )
2016-03-25 16:47:20 -07:00
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. Why are you creating a 'forever' loop?
< br / >
We are creating a forever loop to constantly display the appropriate brightness on the LED display.
## 2. Write the line of code to measure the acceleration with respect to the "y" axis and store this value in a local variable called 'acceleration'.
< br / >
2016-03-29 16:24:11 -07:00
```blocks
2016-03-25 16:47:20 -07:00
let acceleration = input.acceleration("y")
```
## 3. After storing the acceleration in a variable, write the code to take the absolute value of the acceleration, and store this value inside 'acceleration'.
< br / >
2016-03-29 16:24:11 -07:00
```blocks
2016-03-30 16:25:19 -07:00
let acceleration = input.acceleration(Dimension.X)
let accelerationAbsolute = Math.abs(acceleration)
2016-03-25 16:47:20 -07:00
```
2016-11-01 10:42:42 -07:00
## 4. Write the code to use the acceleration value from question 3 to set the brightness on the @boardname@.
2016-03-25 16:47:20 -07:00
< br / >
2016-03-29 16:24:11 -07:00
```blocks
2016-03-30 16:25:19 -07:00
let accelerationX = input.acceleration(Dimension.X)
let accelerationAbsolute = Math.abs(accelerationX)
let accelerationDivided = accelerationX / 4
led.setBrightness(accelerationX)
2016-03-25 16:47:20 -07:00
```