Migrate docs from the other repo
This commit is contained in:
147
docs/reference/js/lessons/prank-wifi/challenges.md
Normal file
147
docs/reference/js/lessons/prank-wifi/challenges.md
Normal file
@ -0,0 +1,147 @@
|
||||
# prank wifi challenges
|
||||
|
||||
create a fake wifi app to trick your friends. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/prank-wifi/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
basic.showString("Check Wifi", 150)
|
||||
basic.forever(() => {
|
||||
let xAccel = math.abs(input.acceleration("x"))
|
||||
let yAccel = math.abs(input.acceleration("y"))
|
||||
let zAccel = math.abs(input.acceleration("z"))
|
||||
let sum = xAccel + yAccel + zAccel
|
||||
if (sum < 1400) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # . .
|
||||
`)
|
||||
} else if (sum >= 1400 && sum < 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . # # .
|
||||
. # # # .
|
||||
# # # # .
|
||||
`)
|
||||
}
|
||||
else if (sum >= 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# . . . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
What if wanted to show the maximum connectivity of wifi instead of just 1, 3, or 4 bars?
|
||||
|
||||
Let's start by changing the first **IF** statement to `if sum <1200`.
|
||||
|
||||
Edit this line: **if** sum <1400 **then**
|
||||
|
||||
Just click on the `1400` and backspace until you can add your own number of `1200`.
|
||||
|
||||
```
|
||||
basic.showString("Check Wifi", 150)
|
||||
basic.forever(() => {
|
||||
let xAccel1 = math.abs(input.acceleration("x"))
|
||||
let yAccel1 = math.abs(input.acceleration("y"))
|
||||
let zAccel1 = math.abs(input.acceleration("z"))
|
||||
let sum1 = xAccel1 + yAccel1 + zAccel1
|
||||
if (sum1 < 1200) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # . .
|
||||
`)
|
||||
} else if (sum1 >= 1400 && sum1 < 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . # # .
|
||||
. # # # .
|
||||
# # # # .
|
||||
`)
|
||||
}
|
||||
else if (sum1 >= 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# . . . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
Let's add an **IF** at the bottom of your code that checks to see if `sum >= to 1200` **and** if `sum <1400`
|
||||
|
||||
```
|
||||
basic.showString("Check Wifi", 150)
|
||||
basic.forever(() => {
|
||||
let xAccel2 = math.abs(input.acceleration("x"))
|
||||
let yAccel2 = math.abs(input.acceleration("y"))
|
||||
let zAccel2 = math.abs(input.acceleration("z"))
|
||||
let sum2 = xAccel2 + yAccel2 + zAccel2
|
||||
if (sum2 < 1200) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # . .
|
||||
`)
|
||||
} else if (sum2 >= 1400 && sum2 < 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . # # .
|
||||
. # # # .
|
||||
# # # # .
|
||||
`)
|
||||
}
|
||||
else if (sum2 >= 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# . . . .
|
||||
`)
|
||||
}
|
||||
if (sum2 >= 1200 && sum2 < 1400) {
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
. . . # #
|
||||
. . # # #
|
||||
. # # # #
|
||||
# # # # #
|
||||
`) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Now it's your turn! Be creative and change the Wifi meter images to your own wifi image you're sure will prank your friends by editing the lines that call `plot image()`.
|
||||
|
92
docs/reference/js/lessons/prank-wifi/quiz-answers.md
Normal file
92
docs/reference/js/lessons/prank-wifi/quiz-answers.md
Normal file
@ -0,0 +1,92 @@
|
||||
# prank wifi quiz answers
|
||||
|
||||
create a fake wifi app to trick your friends #string #forever #abs #var #plot #image #if #math #abs #acceleration #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [prank WiFi tutorial](/microbit/lessons/prank-wifi/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the lines of code that takes the absolute value of the accelerations with respect to the x, y and z axis and stores the values as Local Variables
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let xAccel = math.abs(input.acceleration("x"))
|
||||
let yAccel = math.abs(input.acceleration("y"))
|
||||
let zAccel = math.abs(input.acceleration("z"))
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the lines of code that add all the accelerations together to get the total acceleration and stores the value as a Local Variable called "sum"
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let sum = xAccel + yAccel + zAccel
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the 'If statement' used if the sum of the acceleration value is less than 1400 milli-gravitys. Then write the code that will plot an image of the fake amount of WiFi if the acceleration in this 'If statement'
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (sum < 1400) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # . .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write tje 'If statement' used if the sum of the acceleration value is greater than 1400 milli-gravitys but less than 1680 milli-gravitys. Then write the code that will plot an image of the fake amount of WiFi inside this 'If statement'
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (sum >= 1400 && sum < 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . # # .
|
||||
. # # # .
|
||||
# # # # .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
## 5. Write the 'if statement' needed to display this specific plot image on the device
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (sum >= 1680) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# . . . .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
46
docs/reference/js/lessons/prank-wifi/quiz.md
Normal file
46
docs/reference/js/lessons/prank-wifi/quiz.md
Normal file
@ -0,0 +1,46 @@
|
||||
# prank wifi quiz
|
||||
|
||||
create a fake wifi app to trick your friends #string #forever #abs #var #plot #image #if #math #abs #acceleration #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [prank WiFi tutorial](/microbit/lessons/prank-wifi/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the lines of code that takes the absolute value of the accelerations with respect to the x, y and z axis and stores the values as Local Variables
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the lines of code that add all the accelerations together to get the total acceleration and stores the value as a Local Variable called "sum"
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the 'If statement' used if the sum of the acceleration value is less than 1400 milli-gravitys. Then write the code that will plot an image of the fake amount of WiFi if the acceleration in this 'If statement'
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write tje 'If statement' used if the sum of the acceleration value is greater than 1400 milli-gravitys but less than 1680 milli-gravitys. Then write the code that will plot an image of the fake amount of WiFi inside this 'If statement'
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 5. Write the 'if statement' needed to display this specific plot image on the device
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
Reference in New Issue
Block a user