Merge branch 'master' into cpp
This commit is contained in:
commit
059539b954
45 files changed
+179
-72
No files matched your search
@@ -36,6 +36,14 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
# . . . #
|
# . . . #
|
||||||
. # # # .`);
|
. # # # .`);
|
||||||
});
|
});
|
||||||
|
input.onButtonPressed(Button.B, () => {
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
# . # . #
|
||||||
|
# . . . #
|
||||||
|
. # . # .
|
||||||
|
. . # . .`);
|
||||||
|
});
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onGesture(Gesture.Shake, () => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. . . . .
|
. . . . .
|
||||||
@@ -44,6 +52,7 @@ input.onGesture(Gesture.Shake, () => {
|
|||||||
. # # # .
|
. # # # .
|
||||||
# . . . #`);
|
# . . . #`);
|
||||||
});
|
});
|
||||||
|
basic.showString("BBC micro:bit");
|
||||||
```
|
```
|
||||||
|
|
||||||
## C++ Runtime
|
## C++ Runtime
|
||||||
|
|||||||
@@ -32,5 +32,10 @@ basic.showString("Hi")
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||

|
|
||||||
|
```blocks
|
||||||
|
basic.showString("Z")
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -10,7 +10,10 @@ Answers will vary. In general, plot refers to the code that turns on a specific
|
|||||||
|
|
||||||
## 2. Draw which LED is ON after running this code
|
## 2. Draw which LED is ON after running this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
led.plot(2, 2)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -18,7 +21,10 @@ By default, the position of an LED on *Blink Tutorial* is set to the centre of t
|
|||||||
|
|
||||||
## 3. Draw which LED is ON after running this code
|
## 3. Draw which LED is ON after running this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
led.plot(0, 0)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -29,7 +35,10 @@ This code turns on specific LED. Plot turns on the specified LED on the LED scre
|
|||||||
|
|
||||||
## 4. Draw which LED is ON after running this code
|
## 4. Draw which LED is ON after running this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
led.plot(4, 4)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@@ -12,23 +12,34 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
|||||||
|
|
||||||
## 1. Describe what `plot` does?
|
## 1. Describe what `plot` does?
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 2. Draw which LED is ON after running this code
|
## 2. Draw which LED is ON after running this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
led.plot(2, 2)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 3. Draw which LED is ON after running this code
|
## 3. Draw which LED is ON after running this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
led.plot(0, 0)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 4. Draw which LED is ON after running this code
|
## 4. Draw which LED is ON after running this code
|
||||||
|
|
||||||

|
|
||||||
|
```blocks
|
||||||
|
led.plot(4, 4)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -14,11 +14,9 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
|||||||
|
|
||||||
Gets the compass heading of the micro:bit in degrees
|
Gets the compass heading of the micro:bit in degrees
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
```
|
```
|
||||||
let degrees = input.compassHeading()
|
let degrees = input.compassHeading()
|
||||||
@@ -26,7 +24,6 @@ let degrees = input.compassHeading()
|
|||||||
|
|
||||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
|
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
```
|
```
|
||||||
if (degrees < 45) {
|
if (degrees < 45) {
|
||||||
@@ -34,9 +31,8 @@ if (degrees < 45) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
|
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
```
|
```
|
||||||
if (degrees < 135) {
|
if (degrees < 135) {
|
||||||
@@ -44,9 +40,8 @@ if (degrees < 135) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
|
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
```
|
```
|
||||||
if (degrees < 225) {
|
if (degrees < 225) {
|
||||||
|
|||||||
@@ -12,21 +12,15 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
|||||||
|
|
||||||
## 1. What is the purpose of the 'compass heading' block?
|
## 1. What is the purpose of the 'compass heading' block?
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
|
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## 3. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
|
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## 3. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
|
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -10,13 +10,15 @@ Pause program execution for the specified number of milliseconds.
|
|||||||
|
|
||||||
## 2. Write the code that leaves an image on the screen for 1 second (1000 milliseconds)
|
## 2. Write the code that leaves an image on the screen for 1 second (1000 milliseconds)
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.pause(1000)
|
||||||
|
```
|
||||||
|
|
||||||
## 3. Write the code that leaves an image on the screen for 1.5 seconds (1500 milliseconds)
|
## 3. Write the code that leaves an image on the screen for 1.5 seconds (1500 milliseconds)
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.pause(1500)
|
||||||
|
```
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
@@ -12,19 +12,14 @@ Answer the questions while completing the activity. Pay attention to the dialogu
|
|||||||
|
|
||||||
## 1. Describe what `pause` does?
|
## 1. Describe what `pause` does?
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 2. Write the code that leaves an image on the screen for 1 second (1000 milliseconds)
|
## 2. Write the code that leaves an image on the screen for 1 second (1000 milliseconds)
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 3. Write the code that leaves an image on the screen for 1.5 seconds (1500 milliseconds)
|
## 3. Write the code that leaves an image on the screen for 1.5 seconds (1500 milliseconds)
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -14,27 +14,33 @@ It's a method that runs code when the user holds the GND pin with a finger of on
|
|||||||
|
|
||||||
Create a condition for `on pin pressed (P0)`.
|
Create a condition for `on pin pressed (P0)`.
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
input.onPinPressed(TouchPin.P0, () => {
|
||||||
|
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## 3. What does this line of code doing?
|
## 3. What does this line of code doing?
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
let x = Math.random(9)
|
||||||
|
```
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
It stores random number between 0 and 9 then stores that number in a variable.
|
It stores random number between 0 and 9 then stores that number in a variable.
|
||||||
|
|
||||||
## 4. Why do you have to add 1 to variable x?
|
## 4. Why do you have to add 1 to variable x?
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
let item = 0;
|
||||||
<br/>
|
item = 0;
|
||||||
|
basic.showNumber(item + 1);
|
||||||
|
```
|
||||||
|
|
||||||
You have to add 1 if you want to generate a random number between 1 and 10 .
|
You have to add 1 if you want to generate a random number between 1 and 10 .
|
||||||
|
|
||||||
## 5. Why do you have to hold ground (GND) to make this work on the micro:bit?
|
## 5. Why do you have to hold ground (GND) to make this work on the micro:bit?
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
You have told GND to complete the circuit.
|
You have told GND to complete the circuit.
|
||||||
|
|
||||||
@@ -12,25 +12,28 @@ Answer the questions below while completing the activity. Pay attention to the d
|
|||||||
|
|
||||||
## 1. Describe what `on pin pressed` does?
|
## 1. Describe what `on pin pressed` does?
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 2. Create a condition for on pin pressed (P0).
|
## 2. Create a condition for on pin pressed (P0).
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 3. Describe what this line of code does?
|
## 3. Describe what this line of code does?
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
let x = Math.random(9)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 4. Describe what adding 1 to variable x does?
|
## 4. Describe what adding 1 to variable x does?
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
let item = 0;
|
||||||
|
item = 0;
|
||||||
|
basic.showNumber(item + 1);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 5. Describe why you must hold ground (GND) before pressing (P0) to run a program using `on pin pressed(P0)` on the micro:bit
|
## 5. Describe why you must hold ground (GND) before pressing (P0) to run a program using `on pin pressed(P0)` on the micro:bit
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -12,13 +12,31 @@ This function turns off all the LED lights on the LED screen.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . # . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .
|
||||||
|
`)
|
||||||
|
```
|
||||||
|
|
||||||
## 3. Write the condition that will detect on button A pressed
|
## 3. Write the condition that will detect on button A pressed
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
|
||||||
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## 4. Write the code that will clear show LEDS from the screen after pressing button A
|
## 4. Write the code that will clear show LEDS from the screen after pressing button A
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
basic.clearScreen()
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
@@ -12,19 +12,18 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
|||||||
|
|
||||||
## 1. Describe what "clear screen" does?
|
## 1. Describe what "clear screen" does?
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 2. Write the code that clears an image from the screen
|
## 2. Write the code that clears an image from the screen
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 3. Write the condition that will detect on button A pressed
|
## 3. Write the condition that will detect on button A pressed
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 4. Write the code that will clear show LEDS from the screen after pressing button A
|
## 4. Write the code that will clear show LEDS from the screen after pressing button A
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
@@ -16,13 +16,36 @@ The extra empty image with show LED creates a blinking smiley, allowing the micr
|
|||||||
|
|
||||||
## 3. Draw the image created with this code
|
## 3. Draw the image created with this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .
|
||||||
|
`)
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 4. Write the code to make this image
|
## 4. Write the code to make this image
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .
|
||||||
|
`)
|
||||||
|
basic.showLeds(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`)
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -10,27 +10,45 @@ Use the hints in the [Smiley](/microbit/lessons/smiley/activity) activity to ans
|
|||||||
|
|
||||||
## 1. Describe what `show LEDs` does
|
## 1. Describe what `show LEDs` does
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 2. Why is there an extra empty frame after the smiley face?
|
## 2. Why is there an extra empty frame after the smiley face?
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 3. Draw the image created with this code
|
## 3. Draw the image created with this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .
|
||||||
|
`)
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 4. Draw the images created with this code
|
## 4. Draw the images created with this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .
|
||||||
|
`)
|
||||||
|
basic.showLeds(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`)
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -10,7 +10,17 @@ Run code in the background forever (answers may vary).
|
|||||||
|
|
||||||
## 2. Draw the picture that will be produced with this code
|
## 2. Draw the picture that will be produced with this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.forever(() => {
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@@ -10,21 +10,31 @@ Use the hints in the [snowflake fall activity](/microbit/lessons/snowflake-fall/
|
|||||||
|
|
||||||
## 1. What is a forever loop?
|
## 1. What is a forever loop?
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## 2. Draw the picture that will be produced with this code
|
## 2. Draw the picture that will be produced with this code
|
||||||
|
|
||||||

|
```blocks
|
||||||
|
basic.forever(() => {
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 3. Write the code for a forever loop and show LEDS for these images!
|
## 3. Write the code for a forever loop and show LEDS for these images!
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
## 4. Write the code for a forever loop and show LEDS for these images!
|
## 4. Write the code for a forever loop and show LEDS for these images!
|
||||||
|
|
||||||
@@ -32,5 +42,5 @@ Use the hints in the [snowflake fall activity](/microbit/lessons/snowflake-fall/
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kindscript-microbit",
|
"name": "kindscript-microbit",
|
||||||
"version": "0.0.10",
|
"version": "0.0.14",
|
||||||
"description": "BBC micro:bit target for KindScript",
|
"description": "BBC micro:bit target for KindScript",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"JavaScript",
|
"JavaScript",
|
||||||
@@ -30,6 +30,6 @@
|
|||||||
"typescript": "^1.8.7"
|
"typescript": "^1.8.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"kindscript": "0.1.115"
|
"kindscript": "0.1.119"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user