Merge remote-tracking branch 'upstream/master'
@ -35,7 +35,7 @@ Learn about about the [hardware components](/device) of the micro:bit to make th
|
||||
|
||||
## Programming: Blocks or JavaScript
|
||||
|
||||
The student can program the BBC micro:bit using [Blocks](/blocks) or [JavaScript](/typescript), via the [micro:bit APIs](/reference):
|
||||
The student can program the BBC micro:bit using [Blocks](/blocks) or [JavaScript](/javascript), via the [micro:bit APIs](/reference):
|
||||
|
||||
```blocks
|
||||
basic.showString("Hi!");
|
||||
@ -45,7 +45,7 @@ basic.showString("Hi!");
|
||||
|
||||
When a user has her code ready, she can connect her BBC micro:bit to a computer via a USB cable, so it appears as a mounted drive (named MICROBIT).
|
||||
|
||||
Compilation to ARM thumb machine code from [Blocks](/blocks) or [JavaScript](/typescript) happens in the browser.
|
||||
Compilation to ARM thumb machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser.
|
||||
|
||||
The student is prompted to save the ARM binary program to a file, which she then simply drags to the micro:bit mounted drive,
|
||||
which flashes the micro:bit device with the new program.
|
||||
|
@ -1,6 +1,12 @@
|
||||
# Frequently Asked Questions
|
||||
|
||||
## Where can I get a BBC micro:bit?
|
||||
### Where can I get a BBC micro:bit?
|
||||
|
||||
More information at [http://uk.farnell.com/bbc-microbit](http://uk.farnell.com/bbc-microbit).
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### My micro:bit does not show up as a drive when I connect it to my computer.
|
||||
|
||||
A common cause for this is a broken cable. Pick another USB cable and try it. Otherwise, try another computer as well.
|
@ -11,8 +11,9 @@ to make real programs that work!
|
||||
|
||||
### Happy face
|
||||
|
||||
There are three blocks in the editor (the area to the left).
|
||||
Arrange them to look like this:
|
||||
Use the **Basic** drawer in the editor (to the left)
|
||||
to drag out and arrange three blocks (two `show leds` and one `forever` block)
|
||||
to create this program:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
@ -33,7 +34,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
When you run this program, you will see a smiley face, then a blank
|
||||
When you run this program (click the **Play** button) you will see a smiley face, then a blank
|
||||
screen, then a smiley again -- it never stops! (That's because of the
|
||||
``forever`` block.)
|
||||
|
||||
@ -69,7 +70,7 @@ Click **Compile** to move your program to the BBC micro:bit!
|
||||
|
||||
### Your turn!
|
||||
|
||||
Pile up more ``show leds`` blocks to create your animation! Create an
|
||||
Pile up more ``show leds`` blocks to create an animation! Create an
|
||||
animation with at least 5 pictures. What does this animation show?
|
||||
|
||||
```blocks
|
||||
@ -496,7 +497,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
```
|
||||
Click **Compile** to move your program to the BBC micro:bit!
|
||||
|
||||
## Your turn!
|
||||
|
||||
How else can you make your game better?
|
||||
Ever hear of [Rock Paper Scissors Spock Lizard](http://www.samkass.com/theories/RPSSL.html)?
|
||||
# Want to do more?
|
||||
|
||||
There are [10 great projects](/projects) waiting for you.
|
||||
|
@ -1,10 +1,10 @@
|
||||
# TypeScript
|
||||
# JavaScript
|
||||
|
||||
You can write micro:bit programs in a subset of [TypeScript](https://www.typescriptlang.org).
|
||||
TypeScript itself is a superset of JavaScript, and many micro:bit programs,
|
||||
especially at the beginner's level, are also just plain JavaScript.
|
||||
You can write micro:bit programs in a subset of [TypeScript](https://www.typescriptlang.org), a superset of JavaScript.
|
||||
Many micro:bit programs, especially at the beginner's level, are just plain JavaScript. TypeScript introduces class-based
|
||||
object-oriented programming, such as:
|
||||
|
||||
```js
|
||||
```typescript
|
||||
class Greeter {
|
||||
greeting: string;
|
||||
constructor(message: string) {
|
@ -7,7 +7,7 @@ Measure the acceleration on the micro:bit in the "x" direction.
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing pendulum activity](/lessons/charting/acceleration)
|
||||
Use this activity document to guide your work in the [charting activity](/lessons/charting)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -49,5 +49,3 @@ input.onButtonPressed(Button.B, () => {
|
||||
### Challenge 3
|
||||
|
||||
Add an event handler with `on shake` to change the LED brightness back to a `255`.
|
||||
|
||||
* `Run main` your script to see the LEDs change brightness.
|
||||
|
@ -1,94 +0,0 @@
|
||||
# offset image challenges
|
||||
|
||||
Coding challenges for the offset image tutorial.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following exercise. Your code should look like this:
|
||||
|
||||
```blocks
|
||||
offset = 0
|
||||
basic.forever(() => {
|
||||
if (offset == -4) {
|
||||
basic.showString("Push button A", 150)
|
||||
}
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
. . # . .
|
||||
`).showImage(offset)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
offset = offset + 1
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Create a condition for if button `B` is pressed. We want the image to move to the left when button `B` is pressed.
|
||||
|
||||
```
|
||||
offset = 0
|
||||
basic.forever(() => {
|
||||
if (offset == -4) {
|
||||
basic.showString("Push button A", 150)
|
||||
}
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
. . # . .
|
||||
`).showImage(offset)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
offset = offset + 1
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
offset = offset - 1 // ***
|
||||
}) // ***
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
|
||||
|
||||
Now we want to make sure that the button does not go off the screen to the right. Add a new line that checks to see if offset = 5 after button `A` is pressed.
|
||||
|
||||
If `offset = 5` then prompt the user to move the image to the left by displaying the text: "Push button B".
|
||||
|
||||
```
|
||||
offset = 0
|
||||
basic.forever(() => {
|
||||
if (offset == -4) {
|
||||
basic.showString("Push button A", 150)
|
||||
}
|
||||
if (offset == 5) {
|
||||
basic.showString("Press Button B", 150) // ***
|
||||
}
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
. . # . .
|
||||
`).showImage(offset)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
offset = offset + 1
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
offset = offset - 1
|
||||
})
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now make sure the image does not go off the left side and if it does, prompt the user to push button `A`.
|
||||
|
@ -1,48 +0,0 @@
|
||||
# offset image quiz answers
|
||||
|
||||
shift an image horizontally across the display with offset.
|
||||
|
||||
This is the answer key for the [offset image quiz](/lessons/offset-image/quiz).
|
||||
|
||||
## 1. What is a 'if, then, else statement' ?
|
||||
|
||||
<br/>
|
||||
|
||||
An if-then statement will run a block of code if the condition specified is true. The statement will run the "else" block of code if that condition is false.
|
||||
|
||||
## 2. Consider the message
|
||||
|
||||
Write the line of code that that will create the message "Push button A" (Hint: This message appears `if` the offset is equal -4 then the BBC micro:bit will state "Push Button A").
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (offset == -4) {
|
||||
basic.showString("Push Button A", 150)
|
||||
}
|
||||
```
|
||||
|
||||
## 3. Consider the following image
|
||||
|
||||

|
||||
|
||||
When with this image be displayed?
|
||||
|
||||
<br/>
|
||||
|
||||
When the offset is NOT equal to -4 then the BBC micro:bit will show the image above.
|
||||
|
||||
## 4. Consider the following image
|
||||
|
||||

|
||||
|
||||
Write the two lines of code that cause the `variable` offset to increase by one when button `A` is pressed.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
offset = offset + 1
|
||||
})
|
||||
```
|
||||
|
@ -1,36 +0,0 @@
|
||||
# offset image quiz
|
||||
|
||||
shift an image horizontally across the display with offset.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [offset image activity](/lessons/offset-image/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is an 'if, then, else statement' ?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the line condition that if true, will display the message "Push button A". This message appears if the offset is equal -4 then the BBC micro:bit will state "Push Button A".
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the one line of code to show this image
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the two lines of code that trigger the variable offset to increase by one.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
@ -106,7 +106,7 @@ Science: Welcome! The activity will teach you how to chart the acceleration of t
|
||||
## 6.
|
||||
First, notice that moving the 1st micro:bit in the simulator in any direction, you will change the acceleration value of the 2nd micro:bit. Also, notice that by moving the micro:bit simulator, there is a changing acceleration value of the second micro:bit. Second, the flat colored horizontal line will start a waving line on the 2nd micro:bit to display the value of the strength as measured in milli-gravities. Finally, notice that the LED display will fluctate based on the movement of the 2nd micro:bit simulator.
|
||||
|
||||

|
||||

|
||||
|
||||
## 7.
|
||||
|
||||
|
@ -1,46 +1,55 @@
|
||||
# Ten Projects
|
||||
|
||||

|
||||
### ~avatar avatar
|
||||
|
||||
## [Flashing Heart](/projects/flashing-heart)
|
||||
Here are some cool projects that you can build with your micro:bit!
|
||||
|
||||

|
||||
### ~
|
||||
|
||||
## [Smiley Buttons](/projects/smiley-buttons)
|
||||
|
||||

|
||||
|
||||
## [Love Meter](/projects/love-meter)
|
||||
|
||||

|
||||
|
||||
## [Rock Paper Scissors](/projects/rock-paper-scissors)
|
||||
|
||||

|
||||
|
||||
## [Compass](/projects/compass)
|
||||
|
||||

|
||||
|
||||
## [Hack your headphones](/projects/hack-your-headphones)
|
||||
|
||||

|
||||
|
||||
## [Banana keyboard](/projects/banana-keyboard)
|
||||
|
||||

|
||||
|
||||
## [Telegraph](/projects/telegraph)
|
||||
|
||||

|
||||
|
||||
## [Radio](/projects/radio)
|
||||
|
||||

|
||||
|
||||
## [Watch](/projects/the-watch)
|
||||
|
||||

|
||||
```codecard
|
||||
[{
|
||||
"name": "Flashing Heart",
|
||||
"url":"/projects/flashing-heart",
|
||||
"imageUrl": "/static/mb/projects/a1-display.png"
|
||||
},{
|
||||
"name": "Smiley Buttons",
|
||||
"url":"/projects/smiley-buttons",
|
||||
"imageUrl": "/static/mb/projects/a2-buttons.png"
|
||||
},{
|
||||
"name": "Love Meter",
|
||||
"url":"/projects/lover-meter",
|
||||
"imageUrl":"/static/mb/projects/a3-pins.png"
|
||||
},{
|
||||
"name": "Rock Paper Scissors",
|
||||
"url":"/projects/rock-paper-scissors",
|
||||
"imageUrl":"/static/mb/projects/a4-motion.png"
|
||||
},{
|
||||
"name": "Compass",
|
||||
"url":"/projects/compass",
|
||||
"imageUrl":"/static/mb/projects/a5-compass.png"
|
||||
},{
|
||||
"name": "Hack your headphones",
|
||||
"url":"/projects/hack-your-headphones",
|
||||
"imageUrl":"/static/mb/projects/a6-music.png"
|
||||
},{
|
||||
"name": "Banana keyboard",
|
||||
"url":"/projects/banana-keyboard",
|
||||
"imageUrl":"/static/mb/projects/a7-conductive.png"
|
||||
},{
|
||||
"name": "Telegraph",
|
||||
"url":"/projects/telegraph",
|
||||
"imageUrl":"/static/mb/projects/a8-network.png"
|
||||
},{
|
||||
"name": "Radio",
|
||||
"url":"/projects/radio",
|
||||
"imageUrl":"/static/mb/projects/a9-radio.png"
|
||||
},{
|
||||
"name": "Watch",
|
||||
"url":"/projects/the-watch",
|
||||
"imageUrl":"/static/mb/projects/a10-watch.png"
|
||||
}]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Micro:bit APIs
|
||||
# Reference
|
||||
|
||||
```namespaces
|
||||
basic.showNumber(0);
|
||||
|
@ -6,9 +6,9 @@ Turn off all the LED lights on the [LED screen](/device/screen).
|
||||
basic.clearScreen()
|
||||
```
|
||||
|
||||
### Example: vanishing heart
|
||||
### Example: Vanishing heart
|
||||
|
||||
The following code shows a heart on the screen and then turns off all the LED lights using `clear screen`:
|
||||
The following code shows a heart on the screen and then turns off all the LED lights.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
@ -23,5 +23,5 @@ basic.clearScreen()
|
||||
|
||||
### See also
|
||||
|
||||
[set brightness](/reference/led/set-brightness), [unplot](/reference/led/unplot), [plot](/reference/led/plot), [Image](/reference/images/image), [clear](/reference/basic/clear-screen)
|
||||
[set brightness](/reference/led/set-brightness), [unplot](/reference/led/unplot), [plot](/reference/led/plot), [Image](/reference/images/image)
|
||||
|
||||
|
@ -2,12 +2,13 @@
|
||||
|
||||
Register code to run when the micro:bit receives a command from the paired gamepad.
|
||||
|
||||
## Bluetooth required
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
|
||||
### ~hint
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
|
||||
such as a smartphone, over Bluetooth (Smart).
|
||||
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
|
||||
|
||||
### ~
|
||||
|
||||
```sig
|
||||
devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {})
|
||||
@ -20,3 +21,7 @@ devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {})
|
||||
### See Also
|
||||
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength), [on signal strength changed](/reference/devices/on-signal-strength-changed)
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
```
|
@ -1,15 +1,16 @@
|
||||
# On Signal Strength Changed
|
||||
|
||||
The `on signal strength changed` function.
|
||||
|
||||
Register code to run when the signal strength of the paired device changes.
|
||||
|
||||
## Bluetooth required
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
|
||||
### ~hint
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
|
||||
such as a smartphone, over Bluetooth (Smart).
|
||||
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
|
||||
|
||||
### ~
|
||||
|
||||
|
||||
```sig
|
||||
devices.onSignalStrengthChanged(() => {})
|
||||
```
|
||||
@ -30,5 +31,8 @@ devices.onSignalStrengthChanged(() => {
|
||||
|
||||
### See Also
|
||||
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on notified](/reference/devices/on-notified), [signal strength](/reference/devices/signal-strength)
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength)
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
```
|
@ -1,15 +1,15 @@
|
||||
# raise alert to
|
||||
|
||||
The raise alert to function.
|
||||
|
||||
Raise an alert on a remote device.
|
||||
|
||||
## Bluetooth required
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
|
||||
### ~hint
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
|
||||
such as a smartphone, over Bluetooth (Smart).
|
||||
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
|
||||
|
||||
### ~
|
||||
|
||||
|
||||
```sig
|
||||
export function raiseAlertTo(event: string)
|
||||
@ -23,41 +23,44 @@ export function raiseAlertTo(event: string)
|
||||
|
||||
To tell the connected device to display toast
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.raiseAlertTo("display toast")
|
||||
```
|
||||
|
||||
To tell the connected device to vibrate
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.raiseAlertTo("vibrate")
|
||||
```
|
||||
|
||||
To tell the connected device to play a sound
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.raiseAlertTo("play sound")
|
||||
```
|
||||
|
||||
To tell the connected device to play a ringtone
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.raiseAlertTo("play ringtone")
|
||||
```
|
||||
|
||||
To tell the connected device to find my phone
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.raiseAlertTo("find my phone")
|
||||
```
|
||||
|
||||
To tell the connected device to ring alarm
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.raiseAlertTo("ring alarm")
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [tell camera to](/reference/devices/tell-camera-to), [on notified](/reference/devices/on-notified)
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [tell camera to](/reference/devices/tell-camera-to)
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
```
|
@ -1,36 +0,0 @@
|
||||
# Receive Number
|
||||
|
||||
The broadcast function.
|
||||
|
||||
Reads the next radio packet as a number data packet.
|
||||
|
||||
## Important Security Consideration
|
||||
|
||||
The functions in the ``radio`` namespace allow the BBC micro:bit to communicate with other micro:bits.
|
||||
|
||||
This API does not contain any form of encryption, authentication or authorization. It's purpose is solely for use as a teaching aid to demonstrate how simple communications operates, and to provide a sandpit through which learning can take place.
|
||||
|
||||
For serious applications, BLE should be considered a substantially more secure alternative.
|
||||
|
||||
```sig
|
||||
radio.receiveNumber();
|
||||
```
|
||||
|
||||
### Returns
|
||||
|
||||
* packet - a number received.
|
||||
|
||||
### Examples
|
||||
|
||||
Broadcasts the value of ``acceleration`` x to other micro:bits.
|
||||
|
||||
```
|
||||
radio.onDataReceived(() => {
|
||||
led.plotBarGraph(radio.receiveNumber(), 1023)
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[send number](/reference/radio/send-number), [receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received), [set group](/reference/radio/set-group)
|
||||
|
@ -1,17 +1,17 @@
|
||||
# Signal Strength
|
||||
|
||||
The `signal strength` function.
|
||||
|
||||
Returns the signal strength reported by the paired device from ``0`` (no signal) to ``4`` (full strength).
|
||||
|
||||
## Important Security Consideration
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
|
||||
### ~hint
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
|
||||
such as a smartphone, over Bluetooth (Smart).
|
||||
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
|
||||
|
||||
```
|
||||
devices.signalStrength() : number
|
||||
### ~
|
||||
|
||||
```sig
|
||||
devices.signalStrength();
|
||||
```
|
||||
|
||||
### Returns
|
||||
@ -22,7 +22,7 @@ devices.signalStrength() : number
|
||||
|
||||
Display the signal strength on screen:
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.onSignalStrengthChanged(() => {
|
||||
basic.showNumber(devices.signalStrength(), 150)
|
||||
})
|
||||
@ -30,5 +30,8 @@ devices.onSignalStrengthChanged(() => {
|
||||
|
||||
### See Also
|
||||
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on notified](/reference/devices/on-notified), [on signal strength changed](/reference/devices/on-signal-strength-changed)
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on signal strength changed](/reference/devices/on-signal-strength-changed)
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
```
|
@ -1,23 +1,17 @@
|
||||
# tell camera to
|
||||
|
||||
The tell camera to function.
|
||||
|
||||
Access the photo/video-taking functionality of a remote device using the ``tell camera to`` function.
|
||||
|
||||
## Bluetooth required
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
|
||||
### ~hint
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
|
||||
such as a smartphone, over Bluetooth (Smart).
|
||||
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
|
||||
|
||||
### Block Editor
|
||||
### ~
|
||||
|
||||

|
||||
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function tellCameraTo(event: string)
|
||||
```sig
|
||||
devices.tellCameraTo()
|
||||
```
|
||||
|
||||
### Parameters
|
||||
@ -28,53 +22,56 @@ export function tellCameraTo(event: string)
|
||||
|
||||
To tell the connected device to take a picture:
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("take photo")
|
||||
```
|
||||
|
||||
To tell the connected device to start recording a video
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("start video capture")
|
||||
```
|
||||
|
||||
To tell the connected device to stop recording a video
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("stop video capture")
|
||||
```
|
||||
|
||||
To tell the connected device to toggle front-rear
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("toggle front-rear")
|
||||
```
|
||||
|
||||
To tell the connected device to launch photo mode
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("launch photo mode")
|
||||
```
|
||||
|
||||
To tell the connected device to launch video mode
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("launch video mode")
|
||||
```
|
||||
|
||||
To tell the connected device to stop photo mode
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("stop photo mode")
|
||||
```
|
||||
|
||||
To tell the connected device to stop video mode
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellCameraTo("stop video mode")
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on notified](/reference/devices/on-notified)
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to)
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
```
|
||||
|
@ -45,14 +45,3 @@ To tell the connected device to stop recording audio
|
||||
```
|
||||
devices.tellMicrophoneTo("stop capture")
|
||||
```
|
||||
|
||||
### Other show functions
|
||||
|
||||
* use [tell remote control to](/reference/devices/tell-remote-control-to) to control presentation of media content
|
||||
* use [tell camera to](/reference/devices/tell-camera-to) to control the photo/video recording of connected devices
|
||||
* use [raise alert to](/reference/devices/raise-alert-to) to control the microphone of connected devices
|
||||
|
||||
### See also
|
||||
|
||||
[Devices](/reference/devices)
|
||||
|
||||
|
@ -1,23 +1,17 @@
|
||||
# tell remote control to
|
||||
|
||||
The tell remote control to function.
|
||||
|
||||
Control the presentation of media content available on a remote device using the `tell remote control` to function.
|
||||
|
||||
##
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
|
||||
### ~hint
|
||||
|
||||
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
|
||||
such as a smartphone, over Bluetooth (Smart).
|
||||
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
|
||||
|
||||
### Block Editor
|
||||
### ~
|
||||
|
||||

|
||||
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function tellRemoteControlTo(event: string)
|
||||
```sig
|
||||
devices.tellRemoteControlTo(event: string)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
@ -40,53 +34,57 @@ export function tellRemoteControlTo(event: string)
|
||||
|
||||
To tell the connected device to start playing:
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("play")
|
||||
```
|
||||
|
||||
To tell the connected device to stop playing
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("stop")
|
||||
```
|
||||
|
||||
To tell the connected device to go to next track
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("next track")
|
||||
```
|
||||
|
||||
To tell the connected device to go to previous track
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("previous track")
|
||||
```
|
||||
|
||||
To tell the connected device to go forward
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("forward")
|
||||
```
|
||||
|
||||
To tell the connected device to rewind
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("rewind")
|
||||
```
|
||||
|
||||
To tell the connected device volume up
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("volume up")
|
||||
```
|
||||
|
||||
To tell the connected device volume down
|
||||
|
||||
```
|
||||
```blocks
|
||||
devices.tellRemoteControlTo("volume down")
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[tell camera to](/reference/devices/tell-camera-to), [raise alert to](/reference/devices/raise-alert-to), [on notified](/reference/devices/on-notified)
|
||||
[tell camera to](/reference/devices/tell-camera-to), [raise alert to](/reference/devices/raise-alert-to)
|
||||
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
```
|
||||
|
46
docs/reference/images/create-big-image.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Create Big Image
|
||||
|
||||
Make a big [image](/reference/images/image) (picture) for the micro:bit
|
||||
[LED screen](/device/screen). The big image made of two squares.
|
||||
Each of the squares is five LEDs on a side, like a regular image.
|
||||
|
||||
```blocks
|
||||
images.createBigImage(`
|
||||
. . # . . . . # . .
|
||||
. # # # . . . # . .
|
||||
# . # . # # . # . #
|
||||
. . # . . . # # # .
|
||||
. . # . . . . # . .
|
||||
`);
|
||||
```
|
||||
|
||||
### Example: Flip-flopping arrow
|
||||
|
||||
This program makes a big image with a picture of an arrow pointing up,
|
||||
and an arrow pointing down. If you press button `A`, the program will
|
||||
show the arrow pointing up, which starts `0` LEDs from the left in the
|
||||
big image. If you press button `B`, the program will show the arrow
|
||||
pointing down, which starts `5` LEDs from the left.
|
||||
|
||||
```blocks
|
||||
let arrows = images.createBigImage(`
|
||||
. . # . . . . # . .
|
||||
. # # # . . . # . .
|
||||
# . # . # # . # . #
|
||||
. . # . . . # # # .
|
||||
. . # . . . . # . .
|
||||
`);
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
arrows.showImage(0);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
arrows.showImage(5);
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[Getting Started](/getting-started), [image](/reference/images/image),
|
||||
[create image](/reference/images/create-image),
|
||||
[show image](/reference/images/show-image),
|
||||
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
@ -1,6 +1,7 @@
|
||||
# Create Image
|
||||
|
||||
Create an [Image](/reference/images/image) to show on the [LED screen](/device/screen).
|
||||
Make an [image](/reference/images/image) (picture) for the micro:bit
|
||||
[LED screen](/device/screen).
|
||||
|
||||
```sig
|
||||
images.createImage(`
|
||||
@ -12,24 +13,37 @@ images.createImage(`
|
||||
`)
|
||||
```
|
||||
|
||||
### Example: rock, paper, scissors
|
||||
### Example: Flip-flopping arrow
|
||||
|
||||
The following example shows one of three images (rock, paper, or scissors) when you shake the micro:bit:
|
||||
If you press button `A`, this program will make a picture of an
|
||||
arrow and show it on the LED screen. If you press button `B`, the
|
||||
program will show a picture of the arrow upside-down.
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let rockpaper = images.createImage(`
|
||||
. . . . . # # # # # . . . . #
|
||||
. # # # . # . . . # # # . # .
|
||||
. # # # . # . . . # . # # . .
|
||||
. # # # . # . . . # # # . # .
|
||||
. . . . . # # # # # . . . . #
|
||||
`)
|
||||
rockpaper.showFrame(Math.random(3))
|
||||
})
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# . # . #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`).showImage(0);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# . # . #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`).showImage(0);
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/image/show-image), [scroll image](/reference/image/scroll-image)
|
||||
[Getting Started](/getting-started), [image](/reference/images/image),
|
||||
[create big image](/reference/images/create-big-image),
|
||||
[show image](/reference/images/show-image),
|
||||
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
|
||||
|
@ -1,70 +1,45 @@
|
||||
# Scroll Image
|
||||
|
||||
The scroll image function.
|
||||
|
||||
Scrolls the frames within an [Image](/reference/images/image) on the [LED screen](/device/screen).
|
||||
|
||||
### Block Editor
|
||||
|
||||

|
||||
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function scrollImage(_this: micro_bit.Image, xOffsetPerStep: number, interval: number)
|
||||
```
|
||||
Scroll (slide) an [image](/reference/images/image) (picture) from one
|
||||
side to the other of the [LED screen](/device/screen).
|
||||
|
||||
### Parameters
|
||||
|
||||
* x offset per step : [Number](/reference/types/number) - the number of columns to scroll at a time (horizontal offset). Use a positive number to scroll an image to the right and a negative number to scroll left. To jump from one image frame to the next, use an offset of 5 or -5.
|
||||
* interval (ms) : [Number](/reference/types/number) - the time (in milliseconds) before scrolling by `x offset per step`; the larger the number, the slower the scroll.
|
||||
* ``offset`` is a [number](/reference/types/number) that means
|
||||
how many LEDs to scroll at a time, from right to left or
|
||||
left to right. If you use a positive number like `2`, the image
|
||||
will scroll from the right side of the screen to the left.
|
||||
If you use a negative number like `-2`, the image will scroll
|
||||
in the other direction. If you use `5` or `-5`, the image
|
||||
will scroll one **frame** at a time. (A frame is a part of the
|
||||
image. It is a square with five LEDs on a side). This is
|
||||
useful for **animation**.
|
||||
|
||||
### ~hide
|
||||
* ``interval (ms)`` is a [number](/reference/types/number) that means
|
||||
how many milliseconds to wait before scrolling the amount that
|
||||
``offset`` says. (1000 milliseconds is one second.) The bigger you
|
||||
make this number, the slower the image will scroll.
|
||||
|
||||
```
|
||||
let img = images.createImage(`
|
||||
. . # . . . # # # . . # # # .
|
||||
. . # . . . . . # . . . . # .
|
||||
. . # . . . . # . . . # # # .
|
||||
. . # . . . # . . . . . . # .
|
||||
. . # . . . # # # . . # # # .
|
||||
`)
|
||||
```
|
||||
### Example
|
||||
|
||||
### ~
|
||||
This program scrolls an image of two arrows five LEDs at a time,
|
||||
with a pause of 200 milliseconds between each time it scrolls.
|
||||
Because each frame is five LEDs wide, that means this program
|
||||
will look like it's animating one arrow flipping and flopping.
|
||||
Of course, you can use any two frames you want instead.
|
||||
|
||||
To scroll an image 1 column at a time to the right:
|
||||
|
||||
```
|
||||
img.scrollImage(1, 1000)
|
||||
```
|
||||
|
||||
To scroll an image 5 columns at a time (skip from frame to frame):
|
||||
|
||||
```
|
||||
img.scrollImage(5, 1000)
|
||||
```
|
||||
|
||||
To scroll an image 1 column at a time to the left:
|
||||
|
||||
```
|
||||
img.scrollImage(-1, 500)
|
||||
```
|
||||
|
||||
### Example: scroll through frames
|
||||
|
||||
This example creates an image with 3 frames, then scrolls through the 3 frames:
|
||||
|
||||
```
|
||||
img = images.createImage(`
|
||||
. . # . . . # # # . . # # # .
|
||||
. . # . . . . . # . . . . # .
|
||||
. . # . . . . # . . . # # # .
|
||||
. . # . . . # . . . . . . # .
|
||||
. . # . . . # # # . . # # # .
|
||||
`)
|
||||
img.showImage(0)
|
||||
img.scrollImage(5, 1000)
|
||||
```blocks
|
||||
let arrows = images.createBigImage(`
|
||||
. . # . . . . # . .
|
||||
. # # # . . . # . .
|
||||
# . # . # # . # . #
|
||||
. . # . . . # # # .
|
||||
. . # . . . . # . .
|
||||
`);
|
||||
basic.forever(() => {
|
||||
arrows.scrollImage(5, 200);
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
|
@ -1,51 +1,42 @@
|
||||
# Show Image
|
||||
|
||||
The show image function.
|
||||
|
||||
Show an [Image](/reference/images/image) on the [LED screen](/device/screen), followed by a 400ms pause.
|
||||
|
||||
```
|
||||
export function showImage(_this: micro_bit.Image, xOffset: number)
|
||||
```
|
||||
Show an [image](/reference/images/image) (picture) on the
|
||||
[LED screen](/device/screen). After the micro:bit shows an image, it
|
||||
will pause for 400 milliseconds (1000 milliseconds is one second).
|
||||
|
||||
### Parameters
|
||||
|
||||
* x offset - [Number](/reference/types/number); the horizontal starting point of an image; use 0 for the first frame of the image, 5 for the second frame of the image, 10 for the third frame and so on.
|
||||
* an [image](/reference/images/image) (picture). It is usually a square with five LEDs on a side, but it might be wider.
|
||||
* a [number](/reference/types/number) that says how many LEDs from the left of the picture the micro:bit should start. `0` means start at the first **frame** of the picture, `5` means start at the second frame, `10` means start at the third, and so on.
|
||||
|
||||
### Create image and show image
|
||||
### Example: Flip-flopping arrow
|
||||
|
||||
Use the [image editor](/reference/images/image) to create images using the [create image](/reference/images/create-image) function, and then use `show image` like this:
|
||||
This program makes a big image with a frame of an arrow pointing up,
|
||||
and a frame of an arrow pointing down. If you press button `A`, the
|
||||
program will use ``show image`` to show the arrow pointing up. (It
|
||||
starts `0` LEDs from the left in the big image.) If you press button
|
||||
`B`, the program will use ``show image`` to show the arrow pointing
|
||||
down, which starts `5` LEDs from the left.
|
||||
|
||||
```
|
||||
let img = images.createImage(`
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
img.showImage(0)
|
||||
```
|
||||
|
||||
### Example: display numbers 1-5
|
||||
|
||||
The following example creates an image with 5 frames and then uses a [for loop](/blocks/loops/for) to show each frame on the screen:
|
||||
|
||||
```
|
||||
let img2 = images.createImage(`
|
||||
. . # . . . # # # # . # # # . . . . # . . # # # .
|
||||
. # # . . . . . . # . . . # . . . # # . . # . . .
|
||||
. . # . . . . . # . . . # . . . # # # # . # # # .
|
||||
. . # . . . . # . . . . . # . . . . # . . . . # .
|
||||
. . # . . . # # # # . # # # . . . . # . . # # # .
|
||||
`)
|
||||
for (let i = 0; i < 5; i++) {
|
||||
img2.showImage(i * 5)
|
||||
basic.pause(1000)
|
||||
}
|
||||
```blocks
|
||||
let arrows = images.createBigImage(`
|
||||
. . # . . . . # . .
|
||||
. # # # . . . # . .
|
||||
# . # . # # . # . #
|
||||
. . # . . . # # # .
|
||||
. . # . . . . # . .
|
||||
`);
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
arrows.showImage(0);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
arrows.showImage(5);
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image)
|
||||
|
||||
[Getting Started](/getting-started), [image](/reference/images/image),
|
||||
[create image](/reference/images/create-image),
|
||||
[create big image](/reference/images/create-big-image),
|
||||
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
|
@ -56,5 +56,5 @@ for (let i = 0; i < img2.width() / 5; i++) {
|
||||
|
||||
### See also
|
||||
|
||||
[show image](/reference/images/show-image), [image](/reference/image/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
# Send Number
|
||||
# Send Value
|
||||
|
||||
Broadcast a (name,number) pair to other micro:bits connected via ``radio``.
|
||||
Send a [string]() and [number]() together by ``radio`` to other micro:bits.
|
||||
|
||||
### Parameters
|
||||
|
||||
* name - a string to send
|
||||
* num - a number to send.
|
||||
* a [string](/reference/types/string) to send by radio
|
||||
* a [number](/reference/types/number) to send by radio
|
||||
|
||||
### Simulator
|
||||
|
||||
@ -13,16 +13,29 @@ This function only works on the micro:bit, not in browsers.
|
||||
|
||||
### Example: Broadcasting acceleration
|
||||
|
||||
This example broadcasts the value of your micro:bit's ``acceleration`` in the `x` direction
|
||||
(left and right) to other micro:bits.
|
||||
This kind of program might be useful in a model car or model rocket.
|
||||
This program sends your micro:bit's **acceleration** (amount it is
|
||||
speeding up or slowing down) in the `x` direction (left and right) to
|
||||
other micro:bits. This kind of program might be useful in a model car
|
||||
or model rocket.
|
||||
|
||||
```blocks
|
||||
radio.setGroup(99)
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
radio.sendValue("acc",input.acceleration(Dimension.X))
|
||||
})
|
||||
```
|
||||
|
||||
This program receives the string and number sent by the last program.
|
||||
Then it shows them on the LED screen.
|
||||
|
||||
```blocks
|
||||
radio.setGroup(99)
|
||||
radio.onDataReceived(() => {
|
||||
basic.showString(radio.receiveString());
|
||||
basic.showNumber(radio.receiveNumber());
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received)
|
||||
|
@ -57,7 +57,7 @@ let brightness = led.brightness()
|
||||
|
||||
### Math functions
|
||||
|
||||
The [math library](/reference/math) includes math related functions.
|
||||
The [math library](/blocks/math) includes math related functions.
|
||||
For example, the `absolute` function returns the returns the absolute value of input parameter `x`:
|
||||
|
||||
```blocks
|
||||
|
BIN
docs/static/mb/projects/a1-display.png
vendored
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 20 KiB |
BIN
docs/static/mb/projects/a10-watch.png
vendored
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
BIN
docs/static/mb/projects/a2-buttons.png
vendored
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
BIN
docs/static/mb/projects/a3-pins.png
vendored
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
BIN
docs/static/mb/projects/a4-motion.png
vendored
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
BIN
docs/static/mb/projects/a5-compass.png
vendored
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 38 KiB |
BIN
docs/static/mb/projects/a6-music.png
vendored
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 29 KiB |
BIN
docs/static/mb/projects/a7-conductive.png
vendored
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 28 KiB |
BIN
docs/static/mb/projects/a8-network.png
vendored
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 18 KiB |
BIN
docs/static/mb/projects/a9-radio.png
vendored
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 18 KiB |