Compare commits

..

11 Commits

Author SHA1 Message Date
75461512f7 0.2.4 2016-03-31 17:27:20 -07:00
a7a91459ff Packages published 2016-03-31 17:27:11 -07:00
4bd5b556a6 Bump kindscript to 0.2.6 2016-03-31 17:26:25 -07:00
5b1ccd3978 0.2.3 2016-03-31 17:00:55 -07:00
5552b42c6e Bump kindscript to 0.2.5 2016-03-31 17:00:53 -07:00
a23042a787 update wifi lesson 2016-03-31 16:54:51 -07:00
130768301c update wifi 2016-03-31 16:52:44 -07:00
5ead39cf51 telegraph lesson 2016-03-31 16:45:53 -07:00
e6a1728f6e update wifi lesson 2016-03-31 16:39:32 -07:00
b210e505a2 Merge branch 'master' of https://github.com/Microsoft/kindscript-microbit 2016-03-31 16:28:16 -07:00
b6d81f73bc telegraph lessons 2016-03-31 16:22:35 -07:00
7 changed files with 171 additions and 57 deletions

View File

@ -9,37 +9,37 @@ Complete the following exercise. Your code should look like this:
```blocks
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 xAccel = Math.abs(input.acceleration(Dimension.X))
let yAccel = Math.abs(input.acceleration(Dimension.Y))
let zAccel = Math.abs(input.acceleration(Dimension.Z))
let sum = xAccel + yAccel + zAccel
if (sum < 1400) {
basic.showleds(`
. . . . .
. . . . .
. . # . .
. # # . .
# # # . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. # # . .
# # # . .
`)
} else if (sum >= 1400 && sum < 1680) {
basic.showleds(`
. . . . .
. . . # .
. . # # .
. # # # .
# # # # .
`)
}
else if (sum >= 1680) {
basic.showleds(`
. . . . .
. . . . .
. . . . .
. . . . .
# . . . .
`)
basic.showLeds(`
. . . . .
. . . # .
. . # # .
. # # # .
# # # # .
`)
} else if (sum >= 1680) {
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
# . . . .
`)
}
})
```
**Challenge 1**
@ -53,12 +53,12 @@ Edit this line: if sum is greater than 1400 then just click on the `1400` and ba
```blocks
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 xAccel1 = Math.abs(input.acceleration(Dimension.X))
let yAccel1 = Math.abs(input.acceleration(Dimension.Y))
let zAccel1 = Math.abs(input.acceleration(Dimension.Z))
let sum1 = xAccel1 + yAccel1 + zAccel1
if (sum1 < 1200) {
basic.showleds(`
basic.showLeds(`
. . . . .
. . . . .
. . # . .
@ -66,7 +66,7 @@ basic.forever(() => {
# # # . .
`)
} else if (sum1 >= 1400 && sum1 < 1680) {
basic.showleds(`
basic.showLeds(`
. . . . .
. . . # .
. . # # .
@ -75,7 +75,7 @@ basic.forever(() => {
`)
}
else if (sum1 >= 1680) {
basic.showleds(`
basic.showLeds(`
. . . . .
. . . . .
. . . . .
@ -93,12 +93,12 @@ Let's add an **IF** at the bottom of your code that checks to see if `sum >= to
```blocks
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 xAccel2 = Math.abs(input.acceleration(Dimension.X))
let yAccel2 = Math.abs(input.acceleration(Dimension.Y))
let zAccel2 = Math.abs(input.acceleration(Dimension.Z))
let sum2 = xAccel2 + yAccel2 + zAccel2
if (sum2 < 1200) {
basic.showleds(`
basic.showLeds(`
. . . . .
. . . . .
. . # . .
@ -106,7 +106,7 @@ basic.forever(() => {
# # # . .
`)
} else if (sum2 >= 1400 && sum2 < 1680) {
basic.showleds(`
basic.showLeds(`
. . . . .
. . . # .
. . # # .
@ -115,7 +115,7 @@ basic.forever(() => {
`)
}
else if (sum2 >= 1680) {
basic.showleds(`
basic.showLeds(`
. . . . .
. . . . .
. . . . .
@ -124,7 +124,7 @@ basic.forever(() => {
`)
}
if (sum2 >= 1200 && sum2 < 1400) {
basic.showleds(`
basic.showLeds(`
. . . . #
. . . # #
. . # # #
@ -137,5 +137,5 @@ basic.forever(() => {
**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()`.
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 `showLeds()`.

View File

@ -9,6 +9,8 @@ Telegraph
## Quick Links
* [activity](/microbit/lessons/telegraph/activity)
* [challenges](/microbit/lessons/telegraph/challenges)
## Prior learning/place of lesson in scheme of work

View File

@ -67,10 +67,9 @@ Using the 4th crocodile clip, connect the unattached end of the crocodile clip o
![](/static/mb/lessons/telegraph-0.png)
Your telegraph is ready!
### Step 10
### ~avatar avatar
* Connect the first micro:bit to your computer using your USB cable and run the [telegraph](/microbit/nnudbr) script on it.
* Connect the second micro:bit to your computer using your USB cable and run the [telegraph](/microbit/nnudbr) script on it.
* The first person and second person take turns pressing button A to play the telegraph game!
Excellent, you're ready to continue with the [challenges](/microbit/lessons/telegraph/challenges)!
### ~

View File

@ -0,0 +1,114 @@
# telegraph activity
Build a telgraph #microbit #docs
# micro:bit telegraph
Have you ever tried to communicate through a telegraph? Let's try coding a "Telegraph" on two BBC micro:bits !
Complete the following [guided tutorial](/microbit/lessons/telegraph/activity), your hack should look like this:
![](/static/mb/lessons/telegraph-0.png)
### Step 1
We now need to digitally write to the specified pin (P0) as digital. Let's start by adding the code in the pin drawer that includes 'digital write (0,1) to pin P0'.. Then insert 1 for digital write.
```blocks
pins.digitalWritePin(DigitalPin.P0, 1)
```
### Step 2
We want to add a block to turn on an LED in the middle area of the LED display using plot x, y. So insert the appropriate LED plot x, y.
```blocks
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
```
### Step 3
We want to insert a condition that tells us when to turn on the LED. So insert the if block under logic drawer. Then add a condition that occurs if we do not turn on a LED with plot x, y. We also should plot an LED on the display if button A is pressed. Your code should appear as follows:
```blocks
if (input.buttonIsPressed(Button.A)) {
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
} else {
}
```
### Step 4
We want to write code if button A is NOT pressed. It is important to say that digital write is not on. We also want to turn off all LED lights on the LED screen
```blocks
if (input.buttonIsPressed(Button.A)) {
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
} else {
pins.digitalWritePin(DigitalPin.P0, 0)
basic.clearScreen()
}
```
### Step 5
Let's add a forever loop so this code runs in the background forever. Modify your code so that your code looks like this. Run the code and press Button A.
```blocks
basic.forever(() => {
if (input.buttonIsPressed(Button.A)) {
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
} else {
pins.digitalWritePin(DigitalPin.P0, 0)
basic.clearScreen()
}
})
```
### Step 6
We now need to digitally read to the specified pin (P1) as digital. Let's start by going to the pin drawer and adding digital read pin (0,1) and changing the pin to P1. Now we need to create a condition for digital read pin (0,1). So we go to the logic drawer and select the comparison operator. Then we want to set the comparison operator to 1 to turn on digital read on pin 1. We want to insert a condition that tells us if button A is pressed and we should turn on digital read on pin 1. So insert the if block under logic drawer. Then add a condition that occurs if digital read on P1 is on. Then we want to plot x, y at the x, y coordinates of 2,2. we also want to say that if digital read pin P1 is not on, we want to turn off all LED lights on the screen. Your code should appear as follows:
```blocks
if (pins.digitalReadPin(DigitalPin.P1) == 1) {
led.plot(2, 2);
}
else {
basic.clearScreen();
}
basic.forever(() => {
if (input.buttonIsPressed(Button.A)) {
pins.digitalWritePin(DigitalPin.P0, 1);
led.plot(2, 2);
}
else {
pins.digitalWritePin(DigitalPin.P0, 0);
basic.clearScreen();
}
});
```
Your telegraph is ready!
### Step 7
* Connect the first micro:bit to your computer using your USB cable and run the [telegraph](/microbit/nnudbr) script on it.
* Connect the second micro:bit to your computer using your USB cable and run the [telegraph](/microbit/nnudbr) script on it.
* The first person and second person take turns pressing button A to play the telegraph game!

View File

@ -9,5 +9,5 @@
"dependencies": {
"microbit": "file:../microbit"
},
"installedVersion": "barvfb"
"installedVersion": "rlfgis"
}

View File

@ -1,7 +1,7 @@
{
"name": "microbit",
"description": "The microbit core library",
"installedVersion": "dnarsa",
"installedVersion": "tsmdvf",
"files": [
"README.md",
"core.d.ts",
@ -23,7 +23,10 @@
"id": "microbit",
"name": "BBC micro:bit",
"title": "JavaScript for BBC micro:bit",
"cloud": false,
"cloud": {
"workspace": false,
"packages": true
},
"blocksprj": {
"id": "blocksprj",
"config": {
@ -68,13 +71,9 @@
"isNative": false,
"hasHex": true
},
"serial" : {
"serial": {
"manufacturerFilter": "^mbed$",
"log": true
},
"cloud" : {
"workspace": false,
"packages": true
}
"log": true
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "kindscript-microbit",
"version": "0.2.2",
"version": "0.2.4",
"description": "BBC micro:bit target for KindScript",
"keywords": [
"JavaScript",
@ -30,6 +30,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"kindscript": "0.2.4"
"kindscript": "0.2.6"
}
}