remove "to create new script..."
This commit is contained in:
parent
d28efb3b84
commit
18e637aa28
@ -6,8 +6,6 @@ control images with variables.
|
|||||||
|
|
||||||
Control images with variables.
|
Control images with variables.
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under *Block Editor*.
|
|
||||||
|
|
||||||
Have you ever tried to making beat box sounds? Let's try making a beatbox with code!
|
Have you ever tried to making beat box sounds? Let's try making a beatbox with code!
|
||||||
|
|
||||||
We will register an event handler on the fruit that will execute when two things occur: first, the alligator clip attaches to GND and the other side of the alligator clip is inserted into a banana. Let's start by adding a variable where you can store data. Then rename the variable to "sound". Then set the value of the variable to the note block `A` from the Music drawer. Modify your code so that your code looks like this.
|
We will register an event handler on the fruit that will execute when two things occur: first, the alligator clip attaches to GND and the other side of the alligator clip is inserted into a banana. Let's start by adding a variable where you can store data. Then rename the variable to "sound". Then set the value of the variable to the note block `A` from the Music drawer. Modify your code so that your code looks like this.
|
||||||
|
@ -10,8 +10,6 @@ Let's learn how to show an image on the LED screen.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under the *Block Editor*.
|
|
||||||
|
|
||||||
We will use *show LEDs* to draw an image on the LED screen. This function immediately writes on the screen.
|
We will use *show LEDs* to draw an image on the LED screen. This function immediately writes on the screen.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
|
@ -6,8 +6,6 @@ Turn an LED on and off with forever
|
|||||||
|
|
||||||
### @video td/videos/blink-0
|
### @video td/videos/blink-0
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under *Block Editor*.
|
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
Have you ever tried to blink a flashlight at night? The concept is fairly simply: turn on the light, wait for a little, turn off the light, wait again, and repeat. That's exactly what we need to code to get a blinking LED.
|
Have you ever tried to blink a flashlight at night? The concept is fairly simply: turn on the light, wait for a little, turn off the light, wait again, and repeat. That's exactly what we need to code to get a blinking LED.
|
||||||
|
@ -4,8 +4,6 @@ Measure the acceleration on the micro:bit in the "z" direction.
|
|||||||
|
|
||||||
### ~avatar avatar
|
### ~avatar avatar
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap `New Project` under `Block Editor`.
|
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
Welcome! This activity will teach how to use the 1st micro:bit to chart the second micro:bit's acceleration in the "x" direction. Let's get started!
|
Welcome! This activity will teach how to use the 1st micro:bit to chart the second micro:bit's acceleration in the "x" direction. Let's get started!
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Control images with variables.
|
Control images with variables.
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under *Block Editor*.
|
|
||||||
|
|
||||||
Have you ever tried to making beat box sounds? Let's try making a beatbox with code!
|
Have you ever tried to making beat box sounds? Let's try making a beatbox with code!
|
||||||
|
|
||||||
Let's start by adding a variable where you can store data. Then rename the variable to "sound". Then set the value of the variable to the note block `A` from the Music drawer. Modify your code so that your code looks like this.
|
Let's start by adding a variable where you can store data. Then rename the variable to "sound". Then set the value of the variable to the note block `A` from the Music drawer. Modify your code so that your code looks like this.
|
||||||
|
@ -10,8 +10,6 @@ In this activity, you will learn how to blink an image on the LED screen.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under *Block Editor*.
|
|
||||||
|
|
||||||
Let's start by adding code that plots a heart image on the screen using `show LEDs`. Once you are done coding, don't forget to run your code in the simulator or the micro:bit.
|
Let's start by adding code that plots a heart image on the screen using `show LEDs`. Once you are done coding, don't forget to run your code in the simulator or the micro:bit.
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ Turn an LED on and off with forever loop
|
|||||||
|
|
||||||
### @video td/videos/counter-0
|
### @video td/videos/counter-0
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under *Block Editor*.
|
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
Have you ever tried to create a game counter? The concept is fairly simply: increase the game `score` with `on button pressed` .
|
Have you ever tried to create a game counter? The concept is fairly simply: increase the game `score` with `on button pressed` .
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Construct a pendulum that glows using acceleration.
|
Construct a pendulum that glows using acceleration.
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap `New Project` under `Block Editor`.
|
|
||||||
|
|
||||||
Welcome! This activity will teach how to construct a pendulum that glows using acceleration. Let's get started!
|
Welcome! This activity will teach how to construct a pendulum that glows using acceleration. Let's get started!
|
||||||
|
|
||||||
Create a **forever** loop that will constantly display the appropriate brightness on the LED display.
|
Create a **forever** loop that will constantly display the appropriate brightness on the LED display.
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Play sounds with music blocks.
|
Play sounds with music blocks.
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap `New Project` under `Block Editor`.
|
|
||||||
|
|
||||||
Have you ever tried to play a song on an instrument? Let's try coding the song "Happy Birthday" on the micro:bit !
|
Have you ever tried to play a song on an instrument? Let's try coding the song "Happy Birthday" on the micro:bit !
|
||||||
|
|
||||||
Let's start by adding the code in the music drawer that includes a single musical chord (or pitched sound) with the `play` block. Then insert the chord "C". Once you are done coding, don't forget to run your code in the simulator or the micro:bit.
|
Let's start by adding the code in the music drawer that includes a single musical chord (or pitched sound) with the `play` block. Then insert the chord "C". Once you are done coding, don't forget to run your code in the simulator or the micro:bit.
|
||||||
|
@ -8,40 +8,30 @@ Have you ever tried to making beat box sounds based on the light level? Let's tr
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under *Block Editor*.
|
|
||||||
|
|
||||||
Let's start by adding a variable where you can store data. Then rename the variable to "light". Then set the value of the variable to the block `light level` from the Input drawer. This will gets the `light level` from 0 (dark) to 255 (bright). The light is measured by using various LEDs from the screen. Modify your code so that your code looks like this.
|
Let's start by adding a variable where you can store data. Then rename the variable to "light". Then set the value of the variable to the block `light level` from the Input drawer. This will gets the `light level` from 0 (dark) to 255 (bright). The light is measured by using various LEDs from the screen. Modify your code so that your code looks like this.
|
||||||
|
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let light = 0;
|
let light = input.lightLevel();
|
||||||
light = input.lightLevel();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
We want to play music on button pressed in order to register an event handler that will execute whenever when you run a script and click on button pressed on the simulator. We must start by opening the Input drawer and adding `on button pressed` A. Then add a block `rest` to plays nothing for a `1/16` beat. Modify your code so that your code looks like this.
|
We want to play music on button pressed in order to register an event handler that will execute whenever when you run a script and click on button pressed on the simulator. We must start by opening the Input drawer and adding `on button pressed` A. Then add a block `rest` to plays nothing for a `1/16` beat. Modify your code so that your code looks like this.
|
||||||
|
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
|
|
||||||
let light = 0;
|
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
music.rest(music.beat(BeatFraction.Sixteenth));
|
music.rest(music.beat(BeatFraction.Sixteenth));
|
||||||
light = input.lightLevel();
|
let light = input.lightLevel();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
We click on the Logic drawer then insert a `if do` that will conditionally run code depending on whether the Boolean condition is true or false. Then insert the variable `light` into the first part of the inequality. The variable "light" will appear in the Variables drawer. Finally, we insert 25. Modify your code so that your code looks like this. If the `light level` is `less than` 25, play `ring tone` `C`. If this conditions is not true, play `ring tone` `A`.
|
We click on the Logic drawer then insert a `if do` that will conditionally run code depending on whether the Boolean condition is true or false. Then insert the variable `light` into the first part of the inequality. The variable "light" will appear in the Variables drawer. Finally, we insert 25. Modify your code so that your code looks like this. If the `light level` is `less than` 25, play `ring tone` `C`. If this conditions is not true, play `ring tone` `A`.
|
||||||
|
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let light = 0;
|
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
music.rest(music.beat(BeatFraction.Sixteenth));
|
music.rest(music.beat(BeatFraction.Sixteenth));
|
||||||
light = input.lightLevel();
|
let light = input.lightLevel();
|
||||||
if (light < 25) {
|
if (light < 25) {
|
||||||
music.ringTone(music.noteFrequency(Note.C));
|
music.ringTone(music.noteFrequency(Note.C));
|
||||||
}
|
}
|
||||||
@ -55,11 +45,9 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
We click on the Logic drawer then insert a `less than` sign into the first `if` conditional that will conditionally run code depending on whether the Boolean condition is true or false. Continue this logic to continue with these conditional statements. Click on the Logic drawer. Then we want to add additional conditional statements by clicking on the gear to the left of the `if`. Add 05 `else if` and 01 `else` inside the `if do` block structure. If the `light level` is `less than` 50, play `ring tone` ``D``. If the `light level` is `less than` 100, play `ring tone` ``E``. If the `light level` is `less than` 150, play `ring tone` ``F`` If the `light level` is `less than` 180, play `ring tone` ``G``. If these conditions are not true, `ring tone` ``A``.
|
We click on the Logic drawer then insert a `less than` sign into the first `if` conditional that will conditionally run code depending on whether the Boolean condition is true or false. Continue this logic to continue with these conditional statements. Click on the Logic drawer. Then we want to add additional conditional statements by clicking on the gear to the left of the `if`. Add 05 `else if` and 01 `else` inside the `if do` block structure. If the `light level` is `less than` 50, play `ring tone` ``D``. If the `light level` is `less than` 100, play `ring tone` ``E``. If the `light level` is `less than` 150, play `ring tone` ``F`` If the `light level` is `less than` 180, play `ring tone` ``G``. If these conditions are not true, `ring tone` ``A``.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
|
|
||||||
let light = 0;
|
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
music.rest(music.beat(BeatFraction.Sixteenth));
|
music.rest(music.beat(BeatFraction.Sixteenth));
|
||||||
light = input.lightLevel();
|
let light = input.lightLevel();
|
||||||
if (light < 25) {
|
if (light < 25) {
|
||||||
music.ringTone(music.noteFrequency(Note.C));
|
music.ringTone(music.noteFrequency(Note.C));
|
||||||
}
|
}
|
||||||
@ -79,9 +67,6 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
music.ringTone(music.noteFrequency(Note.A));
|
music.ringTone(music.noteFrequency(Note.A));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* click *compile* and run your code on the micro:bit.
|
* click *compile* and run your code on the micro:bit.
|
||||||
|
@ -8,8 +8,6 @@ Create a love meter with the micro:bit
|
|||||||
|
|
||||||
Welcome! This activity will help you create a love meter with the micro:bit. Let's get started!
|
Welcome! This activity will help you create a love meter with the micro:bit. Let's get started!
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under *Block Editor*.
|
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
Begin by registering an event with `on pin pressed` *P0* to know when someone is holding pin *P0* and pin *Gnd*.
|
Begin by registering an event with `on pin pressed` *P0* to know when someone is holding pin *P0* and pin *Gnd*.
|
||||||
|
@ -10,8 +10,6 @@ Let's learn how to show the lucky number 7 on the LED screen.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](https://www.microbit.co.uk/create-code) page and tap `New Project` under **Block Editor**.
|
|
||||||
|
|
||||||
We will use `show number` to display a number on the screen. The argument (`7`) is the number to display.
|
We will use `show number` to display a number on the screen. The argument (`7`) is the number to display.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Construct a counter that uses acceleration.
|
Construct a counter that uses acceleration.
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap `New Project` under `Block Editor`.
|
|
||||||
|
|
||||||
Welcome! This activity will teach how to construct a pendulum that glows using acceleration. Let's get started!
|
Welcome! This activity will teach how to construct a pendulum that glows using acceleration. Let's get started!
|
||||||
|
|
||||||
Create a **forever** loop that will constantly display the appropriate brightness on the LED display. Now let's measure the acceleration on the `y` axis and store that value in a variable. The `acceleration(y)` function will provide the value.
|
Create a **forever** loop that will constantly display the appropriate brightness on the LED display. Now let's measure the acceleration on the `y` axis and store that value in a variable. The `acceleration(y)` function will provide the value.
|
||||||
|
@ -10,8 +10,6 @@ Welcome! This tutorial will help you create a game of rock paper scissors with t
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ basic.showLeds(`
|
|||||||
`)
|
`)
|
||||||
basic.pause(100)
|
basic.pause(100)
|
||||||
while (true) {}
|
while (true) {}
|
||||||
basic.pause(20)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Objectives
|
## Objectives
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Measure the temperature on the micro:bit
|
Measure the temperature on the micro:bit
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap `New Project` under `Block Editor`.
|
|
||||||
|
|
||||||
Welcome! This activity will teach how to measure the temperature on the micro:bit. Let's get started!
|
Welcome! This activity will teach how to measure the temperature on the micro:bit. Let's get started!
|
||||||
|
|
||||||
We want to display the temperature on shake. In order to do so, we need to register the event `on shake` that will execute whenever the user shakes the micro:bit; in the web browser, click the button labelled "SHAKE" under the simulator to generate a shake event
|
We want to display the temperature on shake. In order to do so, we need to register the event `on shake` that will execute whenever the user shakes the micro:bit; in the web browser, click the button labelled "SHAKE" under the simulator to generate a shake event
|
||||||
|
@ -8,8 +8,6 @@ Measure the acceleration on the micro:bit in the "z" direction.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap `New Project` under `Block Editor`.
|
|
||||||
|
|
||||||
Welcome! This activity will teach how to measure the acceleration on the micro:bit in the "z" direction. Let's get started!
|
Welcome! This activity will teach how to measure the acceleration on the micro:bit in the "z" direction. Let's get started!
|
||||||
|
|
||||||
We want to display the acceleration forever. In order to do so, we need a `forever` loop.
|
We want to display the acceleration forever. In order to do so, we need a `forever` loop.
|
||||||
|
@ -10,8 +10,6 @@ Welcome! This tutorial will teach you how to make a counter that increments when
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
Let's start by creating a **local variable** `count` to keep track of the current count.
|
Let's start by creating a **local variable** `count` to keep track of the current count.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Create a die on the BBC micro:bit
|
Create a die on the BBC micro:bit
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **KindScript**.
|
|
||||||
|
|
||||||
Let's create a condition for when the BBC micro:bit is shaken.
|
Let's create a condition for when the BBC micro:bit is shaken.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -10,8 +10,6 @@ In this activity, you will learn how to blink an image on the LED screen.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](https://www.microbit.co.uk/create-code) page and tap `New Project` under **KindScript**.
|
|
||||||
|
|
||||||
Let's start by adding code that plots a heart image on the screen using `basic->plot image`. Once you are done coding, don't forget to run your code in the simulator or the BBC micro:bit.
|
Let's start by adding code that plots a heart image on the screen using `basic->plot image`. Once you are done coding, don't forget to run your code in the simulator or the BBC micro:bit.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -8,8 +8,6 @@ Welcome! This guided activity will teach how to construct a pendulum that glows
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
Create a **forever** loop that will constantly display the appropriate brightness on the LED display.
|
Create a **forever** loop that will constantly display the appropriate brightness on the LED display.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -10,8 +10,6 @@ Welcome! This tutorial will help you create a guess the number game! Let's get s
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap New Project under **Touch Develop**.
|
|
||||||
|
|
||||||
Add an event handler when button `A` is pressed.
|
Add an event handler when button `A` is pressed.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -10,8 +10,6 @@ Welcome! This tutorial will help you create a love meter with the BBC micro:bit.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
Begin by registering an event with `input->on pin pressed(PO)` to know when someone is holding pin ``P0`` and pin ``Gnd``.
|
Begin by registering an event with `input->on pin pressed(PO)` to know when someone is holding pin ``P0`` and pin ``Gnd``.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -10,8 +10,6 @@ Let's learn how to show the lucky number 7 on the LED screen.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](https://www.microbit.co.uk/create-code) page and tap `New Project` under **Touch Develop**.
|
|
||||||
|
|
||||||
We will use `basic->show number` to display a number on the screen. The first argument (`7`) is the number to display and the second argument (`150`) is duration in milliseconds between column scroll. For example, you can reduce `150` to `100` to speed up the scrolling.
|
We will use `basic->show number` to display a number on the screen. The first argument (`7`) is the number to display and the second argument (`150`) is duration in milliseconds between column scroll. For example, you can reduce `150` to `100` to speed up the scrolling.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -8,17 +8,15 @@ Welcome! This tutorial will help you create a magic 8 ball on the BBC micro:bit.
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer true or false questions.
|
Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer true or false questions.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
basic.showString("Ask a question", 150)
|
basic.showString("Ask a question", 150)
|
||||||
```
|
```
|
||||||
|
|
||||||
Display the number 8.
|
Display the number 8.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
basic.showString("Ask a question", 150)
|
basic.showString("Ask a question", 150)
|
||||||
basic.showNumber(8, 150)
|
basic.showNumber(8, 150)
|
||||||
```
|
```
|
||||||
@ -27,7 +25,7 @@ basic.showNumber(8, 150)
|
|||||||
|
|
||||||
Register code to run when the BBC micro:bit is shaken.
|
Register code to run when the BBC micro:bit is shaken.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
basic.showString("Ask a question", 150)
|
basic.showString("Ask a question", 150)
|
||||||
basic.showNumber(8, 150)
|
basic.showNumber(8, 150)
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
@ -40,7 +38,7 @@ Set **x** equal to a random number with a limit of 3.
|
|||||||
|
|
||||||
Remember the random function in the math library, picks a random number from 0 to the limit, but not including the limit unless it is 0.
|
Remember the random function in the math library, picks a random number from 0 to the limit, but not including the limit unless it is 0.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
basic.showString("Ask a question", 150)
|
basic.showString("Ask a question", 150)
|
||||||
basic.showNumber(8, 150)
|
basic.showNumber(8, 150)
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
@ -52,7 +50,7 @@ Create an if statement for the condition `if x= 2`.
|
|||||||
|
|
||||||
If **x** is 2, display the string 'Yes'
|
If **x** is 2, display the string 'Yes'
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
basic.showString("Ask a question", 150)
|
basic.showString("Ask a question", 150)
|
||||||
basic.showNumber(8, 150)
|
basic.showNumber(8, 150)
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
@ -67,7 +65,7 @@ Create an if statement for the condition `if x = 1`.
|
|||||||
|
|
||||||
If ``x`` is 1, display the string 'No'
|
If ``x`` is 1, display the string 'No'
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
basic.showString("Ask a question", 150)
|
basic.showString("Ask a question", 150)
|
||||||
basic.showNumber(8, 150)
|
basic.showNumber(8, 150)
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
|
@ -10,18 +10,16 @@ Welcome! This tutorial will help you create a game of rock paper scissors with t
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
We want the BBC micro:bit to choose rock, paper, or scissors when it is shaken. Let's begin by creating an `input->on shake` condition so the micro:bit will run code when it is shaken.
|
We want the BBC micro:bit to choose rock, paper, or scissors when it is shaken. Let's begin by creating an `input->on shake` condition so the micro:bit will run code when it is shaken.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, create an image that contains 3 frames: rock, paper, and scissors. We will control which image is shown with `offset`.
|
Next, create an image that contains 3 frames: rock, paper, and scissors. We will control which image is shown with `offset`.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
let img = images.createImage(`
|
let img = images.createImage(`
|
||||||
. . . . . # # # # # . . . . #
|
. . . . . # # # # # . . . . #
|
||||||
@ -35,7 +33,7 @@ input.onGesture(Gesture.Shake, () => {
|
|||||||
|
|
||||||
The BBC micro:bit will look like it's showing 1 frame of the image by displaying the whole image with plot frame and math random. We can help the BBC micro:bit randomly decide which offset to using plot image by math random. The BBC micro:bit will randomly pick the image to display with plot image and the `math->random(3)` function.
|
The BBC micro:bit will look like it's showing 1 frame of the image by displaying the whole image with plot frame and math random. We can help the BBC micro:bit randomly decide which offset to using plot image by math random. The BBC micro:bit will randomly pick the image to display with plot image and the `math->random(3)` function.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
let img1 = images.createImage(`
|
let img1 = images.createImage(`
|
||||||
. . . . . # # # # # . . . . #
|
. . . . . # # # # # . . . . #
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
create an arrow that randomly points to a player. #docs
|
create an arrow that randomly points to a player. #docs
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
Let's begin by adding an `input->on shake` condition to know when the BBC micro:bit is shaken.
|
Let's begin by adding an `input->on shake` condition to know when the BBC micro:bit is shaken.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
a multi-player game that forces each player to reveal a secret or something funny. #docs
|
a multi-player game that forces each player to reveal a secret or something funny. #docs
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
Begin by plotting an "up-arrow" image, which will point to someone.
|
Begin by plotting an "up-arrow" image, which will point to someone.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -10,8 +10,6 @@ Welcome! This tutorial will teach how to measure the acceleration on the micro:b
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
To create a new script, go to the [Create Code](/create-code) page and tap *New Project* under **Touch Develop**.
|
|
||||||
|
|
||||||
We want to display the acceleration forever. In order to do so, we need a `basic->forever` loop.
|
We want to display the acceleration forever. In order to do so, we need a `basic->forever` loop.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user