This commit is contained in:
Peli de Halleux 2016-06-14 13:18:43 -07:00
commit 2ab2535966
213 changed files with 256 additions and 524 deletions

8
docs/blocks.md Normal file
View File

@ -0,0 +1,8 @@
# Blocks language
```namspaces
for (let i = 0;i<5;++i) {}
if (true){}
let x = 0;
Math.random(5);
```

View File

@ -13,10 +13,15 @@ The micro:bit LED screen
```
The micro:bit LED screen consists of 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down).
In the screen above, we created a checkerboard pattern using the LEDs.
### Which LED?
You use ``x , y`` coordinates to specify a particular LED in the grid; where ``x`` is the horizontal position and ``y`` is the vertical position (0, 1, 2, 3, 4). To figure out the ``x``, ``y`` coordinates, position your micro:bit horizontally, like a credit card (see picture above).
You use `(x ,y)` coordinates to specify a particular LED in the grid;
where `x` is the horizontal position (0,1,2,3,4) and `y` is the vertical position
(0, 1, 2, 3, 4).
To figure out the ``x``, ``y`` coordinates, position your micro:bit horizontally, like a credit card (see picture above).
Here are the x, y coordinates for the LEDs in the 5X5 grid:
@ -30,11 +35,17 @@ Here are the x, y coordinates for the LEDs in the 5X5 grid:
`(0,4)` `(1,4)` `(2,4)` `(3,4)` `(4,4)`
The x, y coordinates for the LED in the centre of the grid are `2, 2`. Starting from `0, 0` count over 2 columns and then down 2 rows.
The x, y coordinates for the LED in the centre of the grid are `(2,2)`. Starting from `(0,0)` count over 2 columns and then down 2 rows.
### Check your understanding
Which LEDs are turned on in the checkboard pattern above?
### Row, column - 1
Since the row and column numbers start at 0, an easy way to figure out the x, y coordinates is to subtract 1 from the row and column number (when counting from 1). In other words, to specify the LED in the 4th column 5th row, subtract 1 from each number to get coordinates `3, 4`.
Since the row and column numbers start at 0, an easy way to figure out the (x,y) coordinates
is to subtract 1 from the row and column number (when counting from 1).
In other words, to specify the LED in the 4th column 5th row, subtract 1 from each number to get coordinates `(3,4)`.
### Turn a LED on/off
@ -42,8 +53,11 @@ Use [plot](/reference/led/plot) and [unplot](/reference/led/unplot) to turn a LE
```blocks
led.plot(0,0);
led.plot(1,1);
basic.pause(1000);
led.unplot(0,0)
led.unplot(0,0);
basic.pause(1000);
led.unplot(1,1);
```
### Is a LED on/off?

View File

@ -24,10 +24,10 @@ input.onButtonPressed(Button.B, () => {
});
```
* **[getting started](/getting-started)**
* **[getting started](/getting-started)**
* Get started with [projects](/projects)
* Browse the [API reference](/reference)
* Learn more about the [device](/device)
* Get started with [projects](/projects)
* Frequently Asked Question [faq](/faq)
* Follow up with the [release notes](/release-notes)

View File

@ -4,7 +4,7 @@
Are you ready to build cool BBC micro:bit programs?
Here are some challenges for you. Unscramble the blocks in the editor
Here are some challenges for you. Unscramble the blocks in the editor
to make real programs that work!
## ~

View File

@ -1,21 +0,0 @@
# banana keyboard blocks lesson
display beautiful images on the BBC micro:bit.
## Topic
Music
## Quick Links
* [activity](/lessons/banana-keyboard/activity)
## Prior learning/place of lesson in scheme of work
Learn how to convert your BBC micro:bit into a music player using pins P0 and GND, earphones (or speakers), as well as crocodile clips (or spring clips). The connect fruit using pins P1 and GND.
## Objectives
* learn how to setup the BBC micro:bit with earphones to play music
* learn how to setup the BBC micro:bit with fruit be the musical instrument

View File

@ -1,20 +0,0 @@
# hack your headphones lesson
display beautiful images on the BBC micro:bit.
## Topic
Hack your headphone
## Quick Links
* [activity](/lessons/hack-your-headphones/activity)
## Prior learning/place of lesson in scheme of work
Learn how to convert your BBC micro:bit into a music player using pins P0 and GND, headphones (or speakers), as well as crocodile clips (or spring clips).
## Objectives
* learn how to setup the BBC micro:bit with headphones to play music

View File

@ -1,21 +0,0 @@
# light beatbox
display beautiful images on the BBC micro:bit.
## Topic
Music
## Quick Links
* [activity](/lessons/light-beatbox/activity)
## Prior learning/place of lesson in scheme of work
Learn how to make a light beatbox music player using the light sensor. We will be learning how to code musical notes using light level, a local variable, conditionals, on button pressed as well as simple commands such as ring tone and rest.
## Objectives
* learn how to control the light sensor on the BBC micro:bit
* learn how to code music on the BBC micro:bit

View File

@ -1,62 +0,0 @@
# rock paper scissors lesson
A game against the BBC micro:bit.
## Topic
Local Variables
## Quick Links
* [activity](/lessons/rock-paper-scissors/activity)
* [challenges](/lessons/rock-paper-scissors/challenges)
## Class
Year 7
## Prior learning/place of lesson in scheme of work
Learn how to create a **local variable**, `var t :=time` where you can store data, so that you can use it in your code. We will be learning how to create a classic rock paper scissors game using global variables, input on shake, local variables, math random as well as simple commands such as create image, show image, show string, and show number.
## Documentation
```cards
input.onGesture(Gesture.Shake, () => {})
Math.random(3)
let x = 0
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
```
## Objectives
* learn how to create a condition so the micro:bit will run code when it is shaken
* learn how to create a local variable for a place where you can store data
* learn how to create an image to show on the micro:bit's LED screen
* learn how to show an image on the micro:bit's LED screen
## Progression Pathways / Computational Thinking Framework
#### Algorithms
* Uses diagrams to express solutions.(AB)
* Represents solutions using a structured notation (AL) (AB)
#### Programming & Development
* Creates programs that implement algorithms to achieve given goals (AL)
* Declares and assigns variables(AB)
* Selects the appropriate data types(AL) (AB
#### Data & Data Representation
* Defines data types: real numbers and Boolean (AB)
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation

View File

@ -1,121 +0,0 @@
# rock paper scissors activity
A classic game against the micro:bit.
### ~avatar avatar
Welcome! This tutorial will help you create a game of rock paper scissors with the micro:bit. Let's get started!
### ~
We want the micro:bit to choose rock, paper, or scissors when it is shaken. Let's begin by creating an on shake condition so the micro:bit will run code when it is shaken.
```blocks
input.onGesture(Gesture.Shake, () => {
})
```
Next, create a variable and store pick random number from 0 to 2. On shake, a number will be randomly picked from 0-2. We will randomly display an image based on the random number returned.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
})
```
The micro:bit will look like it's showing 1 frame of the image by displaying the whole image when pick random is equal to 2. We can help the micro:bit randomly decide which image to use by pick random. The micro:bit will randomly pick the image to display with show LEDs and the pick random function.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
}
})
```
The micro:bit will look like it's showing 1 frame of the image by displaying the whole image when pick random is equal to 1. We can help the micro:bit randomly decide which image to use by pick random. The micro:bit will randomly pick the image to display with show LEDs and the pick random function.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
}
})
```
The micro:bit will look like it's showing 1 frame of the image by displaying the whole image when pick random is not equal to 2 and not equal to 1. We can help the micro:bit randomly decide which image to use by pick random. The micro:bit will randomly pick the image to display with show LEDs and the pick random function.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
```
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/rock-paper-scissors/challenges)!
### ~

View File

@ -1,133 +0,0 @@
# rock paper scissors challenges
Coding challenges for rock paper scissors.
## Before we get started
Complete the following [guided activity](/lessons/rock-paper-scissors/activity) , your code should look like this:
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
```
### Challenge 1
When the A button is pressed, increment the score by 1. You can select Game drawer then add change score by 1.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(2)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
input.onButtonPressed(Button.A, () => {
game.addScore(1)
})
```
* Click *run* to execute your code in the simulator
### Challenge 2
After incrementing the score, display the total number of wins you have.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(2)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
input.onButtonPressed(Button.A, () => {
game.addScore(1)
basic.showString("WINS:")
basic.showNumber(game.score())
})
```
* Run and compile the code to see if it works as expected.
### Challenge 3
You have successfully tracked and displayed the number of wins on the micro:bit! However, what about losses? Use the Game drawer to change score by -1 when button `B` is pressed.
* Run and compile the code to see if it works as expected.

View File

@ -1,74 +0,0 @@
# rock paper scissors quiz
shift an image horizontally across the display with offset.
## Name
## Directions
Use this activity document to guide your work in the [rock paper scissors tutorial](/lessons/rock-paper-scissors/activity).
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. Describe what `offset` does?
<br/>
## 2. Draw which LEDs are ON after running this code and the random number returned is 0
```blocks
let img = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
let offset = Math.random(3) * 5
img.showImage(offset)
```
![](/static/mb/lessons/night-light-2.png)
<br/>
<br/>
## 3. Draw which LEDs are ON after running this code with an offset of 5. This would occur if the random number returned is 1.
```blocks
let img_ = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
let offset_ = Math.random(3) * 5
img.showImage(offset)
```
![](/static/mb/lessons/night-light-2.png)
<br/>
<br/>
## 4. Draw which LEDs are ON after running this code with an offset of 10. This would occur if the random number returned is 2.
```blocks
let img_1 = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
let offset_1 = Math.random(3) * 5
img.showImage(offset)
```
![](/static/mb/lessons/night-light-2.png)
<br/>

View File

@ -1,24 +0,0 @@
# telegraph lesson
display beautiful images on the BBC micro:bit.
## Topic
Telegraph
## Quick Links
* [activity](/lessons/telegraph/activity)
* [challenges](/lessons/telegraph/challenges)
## Prior learning/place of lesson in scheme of work
Learn how to convert your BBC micro:bit into a telegraph using a second BBC micro:bit as well as pin P1, P2, 3V, GND,
and crocodile clips (or spring clips). The connect BBC micro:bit uses pins P1, P2, 3V, GND.
## Objectives
* learn how to setup the BBC micro:bit with crocodile clips
* learn how to telegraph to another BBC micro:bit

View File

@ -22,19 +22,19 @@
![](/static/mb/projects/a5-compass.png)
## [Hack your headphones](/lessons/hack-your-headphones/activity)
## [Hack your headphones](/projects/hack-your-headphones)
![](/static/mb/projects/a6-music.png)
## [Banana keyboard](/lessons/banana-keyboard/activity)
## [Banana keyboard](/projects/banana-keyboard)
![](/static/mb/projects/a7-conductive.png)
## [Telegraph](/lessons/telegraph/activity)
## [Telegraph](/projects/telegraph)
![](/static/mb/projects/a8-network.png)
## Radio
## [Radio](/projects/radio)
![](/static/mb/projects/a9-radio.png)

View File

@ -95,6 +95,6 @@ Tap your banana instrument to play sound against... the fruit!
### ~avatar boothing
Excellent, you're ready to continue with the [challenges](/lessons/banana-keyboard/challenges)!
Excellent, you're ready to continue with the [challenges](/banana-keyboard-challenges)!
### ~

View File

@ -1,4 +1,4 @@
# compass activity
# compass
![](/static/mb/projects/a5-compass.png)

View File

@ -1,6 +1,29 @@
# flashing heart
![](/static/mb/projects/a1-display.png)
Use the LEDs to display a flashing heart.
### ~avatar avatar
```sim
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
basic.pause(500);
basic.clearScreen();
basic.pause(500);
})
```
Use the LEDs to display a flashing heart, and then create
an animation of a broken heart. :(
## [START PROJECT](/#follow:/projects/flashing-heart)
### ~
## Step 1

View File

@ -1,4 +1,4 @@
# light beatbox activity
# hack your headphones challenges
Control sound with the light level.
@ -71,10 +71,3 @@ input.onButtonPressed(Button.A, () => {
* click *compile* and run your code on the micro:bit.
### ~avatar avatar
Excellent, you're ready to continue by connecting your headphones with these [challenges](/lessons/hack-your-headphones/activity)!
### ~

View File

@ -1,4 +1,4 @@
# hack your headphones activity
# hack your headphones
Hack your headphones
@ -52,10 +52,10 @@ You hacked your headphones!
### Step 6
Connect your micro:bit to your computer using your USB cable and program [light beatbox](/lessons/light-beatbox/activity) music on it. Press the reset button to restart your music player!
Connect your micro:bit to your computer using your USB cable and program [light beatbox](/projects/hack-your-headphones-challenges) music on it. Press the reset button to restart your music player!
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/light-beatbox/activity)!
Excellent, you're ready to continue with the [challenges](/projects/hack-your-headphones-challenges)!
### ~

View File

@ -1,3 +1,5 @@
# love meter
![](/static/mb/projects/a3-pins.png)
Use pins P0, P1 and P2 to change the display by creating a circuit with your body.

68
docs/projects/radio.md Normal file
View File

@ -0,0 +1,68 @@
# radio
Measure the acceleration on the micro:bit in the "x" direction.
### ~avatar avatar
Welcome! This activity will teach how to use the micro:bit to chart the acceleration in the "x" direction. Let's get started!
### ~
Let's measure `acceleration (mg)` in the "x" direction. Get the acceleration value (milli g-force), in one of three specified dimensions.
```blocks
input.acceleration(Dimension.X)
```
### ~
Use the plot bar chart to visualize the acceleration on the LED screen of the micro:bit in the specified range. You implement plot Bar Graph to display a vertical bar graph based on the "value" and "high" value. Then you must insert acceleration in the X dimension to measure the acceleration.
```blocks
basic.forever(() => {
led.plotBarGraph(input.acceleration(Dimension.X), 0)
})
```
### ~
Notice that moving the micro:bit in the simulator from left to right (x direction) changes the values beneath the micro:bit in a range from 1023 to -1023 as measured in milli-gravities. By hovering over the micro:bit from left to right, you can observe changing values beneath the micro:bit simulator. Also, the LEDs shown on the Bar Graph fluctates based on the movement of the micro:bit simulator in the x direction. The line underneath the micro:bit simulator reflect the acceleration in the x direction.
NOTE: The colors of the charts reflect the color of the micro:bit simulator. In this instance, the micro:bit is yellow. So the color of the data line reflects the color of the micro:bit
![](/static/mb/data4.png)
### ~
Vigorously move the micro:bit in the micro:bit simulatator by moving the micro:bit image from side to side. Every time the micro:bit moves in the x direction in the simulator, you are generating data points that can be reviewed in Excel. The more attempts to move the micro:bit from side to side, the more data being saved in Excel. After you have vigarously moved the micro:bit simulator from side to side for a sufficient amount of time, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel that can be graphed in Excel.
### ~
We want to chart the data collected by using a tool in Excel.
The final part of this experiment is opening and reviewing the data in the Excel CSV file. Simply click on the line beneath the simulator. A CSV file will be generated to display the data points collected by moving the micro:bit in the X direction. Then click or tap on the data Excel file that was downloaded to your local ``Downloads`` Folder.
### ~
First, click or tap on the first two columns (A, B) to include the time of the data being collected; b) the results of acceleration data on the micro:bit
![](/static/mb/data7.png)
Use the Recommended Charts command on the Insert tab to quickly create a chart thats just right for your data.
* Select the data that you want to include in your chart.
* Click Insert > Recommended Charts.
![](/static/mb/lessons/chart1.png)
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data. Pick the **scatter plot**.
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/projects/radio-challenges)
### ~

View File

@ -1,3 +1,5 @@
# smiley buttons
![](/static/mb/projects/a2-buttons.png)
Use buttons to show a smiley or frowny face.

View File

@ -70,6 +70,6 @@ Using the 4th crocodile clip, connect the unattached end of the crocodile clip o
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/telegraph/challenges)!
Excellent, you're ready to continue with the [challenges](/projects/telegraph-challenges)!
### ~

View File

@ -1,6 +1,6 @@
![](/static/mb/projects/a10-watch.png)
# micro:bit watch
# the watch
![](/static/mb/lessons/the-watch-0.png)

View File

@ -21,11 +21,4 @@ serial.writeNumber(0);
control.inBackground(() => {
});
```
<!-- No language reference for now, until
for (let i = 0;i<5;++i) {}
if (true){}
let x = 0;
Math.random(5);
-->
```

View File

@ -15,9 +15,9 @@ basic.showLeds(`
### Parameters
* `leds` is a [string](/reference/types/string) that means which LEDs are on and off.
* `leds` is a [string](/reference/types/string) that controls which LEDs are on and off.
* `interval` is an optional [number](/reference/types/number) that means how many milliseconds to wait after showing a picture.
If you are programming with blocks, `interval` starts out as 400 milliseconds.
If you are programming with blocks, `interval` is set at 400 milliseconds.
### Example

View File

@ -1,6 +1,6 @@
# Brightness
Find how bright the [LED screen](/device/screen) is.
Find how bright the [LED screen](/device/screen) is _when it is turned on_.
```sig
led.brightness();
@ -8,11 +8,11 @@ led.brightness();
### Returns
* a [Number](/reference/types/number) that means how bright the screen is, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright.
* a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on.
### Example: highest brightness
This program makes the screen completely bright if it is not that way already:
This program makes the screen completely bright when it is turned on (if it is not that way already):
```blocks
if (led.brightness() < 255) {
@ -20,6 +20,20 @@ if (led.brightness() < 255) {
}
```
### Example: change brightness
This program makes the screen brightness 100% (255). Then it turns on
the center LED (`2, 2`), waits for one second and then sets the screen
brightness to 50% (128):
```blocks
led.setBrightness(255)
led.plot(2, 2)
basic.pause(1000)
led.setBrightness(led.brightness() / 2)
```
### See also
[set brightness](/reference/led/set-brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out)

View File

@ -1,6 +1,7 @@
# Set Brightness
Sets the brightness of the [LED screen](/device/screen).
Make the [LED screen](/device/screen) as bright as you say when it is
turned on.
```sig
led.setBrightness(121)
@ -8,17 +9,19 @@ led.setBrightness(121)
### Parameters
* value : [Number](/reference/types/number) - the brightness of the LED screen expressed as a number between 0 and 255
* a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on.
### Example: change brightness
The following example sets the screen brightness to 100% (255), turns on LED `2, 2`, waits for a second and then sets the screen brightness to 50% (127):
This program makes the screen brightness 100% (255). Then it turns on
the center LED (`2, 2`), waits for one second, and then sets the screen
brightness to 50% (128):
```blocks
led.setBrightness(255)
led.plot(2, 2)
basic.pause(1000)
led.setBrightness(127)
led.setBrightness(led.brightness() / 2)
```
### See also

View File

@ -1,6 +1,5 @@
# Lessons
### @short Lessons
### ~column
@ -51,9 +50,6 @@
### ~column
## Maker
* [Hack your Headphones](/lessons/hack-your-headphones), create music on the BBC micro:bit by hacking your headphones
* [Banana Keyboard](/lessons/banana-keyboard), create music with fruits
* [Telegraph](/lessons/telegraph), play the telegraph game between two BBC micro:bits
* [Pogo](/lessons/pogo), create a pogo game to test your jumping abilities
## Science

View File

@ -0,0 +1,88 @@
# Challenge
### ~avatar avatar
Welcome! The activity will teach you how to use the acceleration of the 1st micro:bit and to visualize the acceleration on the 2nd micro:bit.
Let's get started!
### ~
Let's measure `acceleration (mg)` and then `send number`. `Acceleration` is measured in **milli-gravities**, so a value of -1000 is equivalent to -1g or -9.81m/s^2. We will be able to get the acceleration value (g-force), in the specified "x" dimension. `Send number` will broadcast a number data packet to other micro:bits connected via radio.
```blocks
radio.sendNumber(input.acceleration(Dimension.X));
```
### ~
We want to display the acceleration forever. In order to do so, we need a `forever` loop. A forever loop will repeat code in the background forever.
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X));
});
```
### ~
We want to register code to run when a packet is received over radio. We can implement this code by adding `on data received`.
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X))
})
radio.onDataReceived(() => {
})
```
### ~
Finally, we want to chart the acceleration. So we must first implement `plot bar graph`. `Plot Bar Graph` will display a vertical bar graph based on the value and high value. In order to transfer the receive the number from the 1st micro:bit, we must implement `receive number` to constantly display a vertical bar graph based on the value. Remember, the value will equal to the micro:bit's acceleration in the "x" direction.
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X))
})
radio.onDataReceived(() => {
led.plotBarGraph(radio.receiveNumber(), 1023)
})
```
### ~
Notice that moving the micro:bit the farthest direction in the x direction will be -1023 on the charting beneath the simulator. The second observation will be that the LEDs will be full brightness on the 2nd micro:bit. There is a single LED turned on with the 1st micro:bit. Additionally, the graphs will reflect 0 acceleation for the 1st micro:bit. In this scenario, if you are adjusting the acceleration in the simualator, you are also changing your chart that will be produced.
![](/static/mb/acc.png)
### ~
NOTE: The colors of the charts reflect the color of the micro:bit simulator. In this instance, the micro:bits are blue and green. So the colors of the line graphs reflect the colors of the micro:bit
### ~
After running this simulation several seconds by moving the micro:bit side to side in the x direction, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel. We will graph the fluctuating acceleration of the simulation experiment.
![](/static/mb/acc2.png)
### ~
Finally, you must open the Excel CSV file by clicking on the data.xls file that was downloaded to Downloads Folder.
![](/static/mb/data3.png)
Use the Recommended Charts command on the Insert tab to quickly create a chart thats just right for your data.
* Select the data that you want to include in your chart.
* Click Insert > Recommended Charts.
![](/static/mb/lessons/chart1.png)
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data. Pick the **scatter plot**.
![](/static/mb/chart_title.png)
* Use the Chart Elements, Chart Styles, and Chart Filters buttons next to the upper-right corner of the chart to add chart elements like axis titles or data labels, to customize the look of your chart
![](/static/mb/elements_styles_filters.png)
### ~
Have fun reviewing your simulation and analyze the acceleration by chart the Excel data using Excel.
* Connect the first micro:bit to your computer using your USB cable and run the charting script on it.
* Connect the second micro:bit to your computer using your USB cable and run the charting script on it.
* The first person and second person take turns tilting the micro:bit in the "x" direction while the other player charts the data on the micro:bit!
* Review and analyze the actual micro:bit device acceleration data on Excel
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"

Some files were not shown because too many files have changed in this diff Show More