pxt-calliope/docs/lessons/glowing-pendulum.md

56 lines
1.4 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# glowing pendulum blocks lesson
construct a pendulum that glows using acceleration #var #acceleration #abs #brightness #plot #docs
## Topic
Acceleration
## Quick Links
* [activity](/microbit/lessons/glowing-pendulum/activity)
* [challenges](/microbit/lessons/glowing-pendulum/challenges)
2016-03-31 01:25:19 +02:00
* [quiz](/microbit/lessons/glowing-pendulum/quiz)
* [quiz answers](/microbit/lessons/glowing-pendulum/quiz-answers)
2016-03-26 00:47:20 +01:00
## Prior learning/place of lesson in scheme of work
Learn how to get the acceleration **acceleration**, `acceleration` value (g-force), in one of three specified dimensions. We will be learning how to get the acceleration using forever loop, a local variable, acceleration, the math library, as well as simple commands, such as led set brightness and led plot all.
## Documentation
2016-03-30 00:59:00 +02:00
```docs
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
basic.forever(() => {
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
})
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
let x = 0
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
input.acceleration(Dimension.X)
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
Math.abs(0)
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
led.setBrightness(255)
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
```
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
## Objectives
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
* learn how to repeat code in the background forever
* learn how create a local variable to store data, so that you can use it in your code
* learn how to get the acceleration value (g-force), in one of three specified dimensions
* learn how to return the absolute value
* learn how to sets the brightness of the LED screen
* learn how to turn on all the LED lights on the LED screen
2016-03-26 00:47:20 +01:00