parent
c9e8cd4e78
commit
4f57c77b30
@ -122,22 +122,22 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
})
|
||||
```
|
||||
|
||||
@ -197,7 +197,7 @@ Notes
|
||||
|
||||
Clean up your coding workspace before you do a final save! What does this mean?
|
||||
|
||||
* It means that only the code and blocks that you are using in your program are still in the workspace.
|
||||
* It means that only the code and blocks that you are using in your program are still in the workspace.
|
||||
* Remove (delete) any other blocks that you may have dragged into the coding workspace as you were experimenting and building your program.
|
||||
|
||||
## Save and download
|
||||
@ -208,23 +208,23 @@ Here is the complete program:
|
||||
```blocks
|
||||
// Display a happy face when button A is pressed.
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
})
|
||||
// Display a sad face when button B is pressed.
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
})
|
||||
basic.clearScreen()
|
||||
```
|
||||
|
@ -161,26 +161,25 @@ Headband Charades Complete Program (simple version - no time limit or scoring):
|
||||
let index = 0
|
||||
let arrayWords: string[] = []
|
||||
input.onGesture(Gesture.ScreenUp, () => {
|
||||
basic.showString(arrayWords[index])
|
||||
basic.showString(arrayWords[index])
|
||||
})
|
||||
input.onGesture(Gesture.ScreenDown, () => {
|
||||
led.stopAnimation()
|
||||
basic.clearScreen()
|
||||
if (index < arrayWords.length - 1) {
|
||||
index += 1
|
||||
} else {
|
||||
game.gameOver()
|
||||
}
|
||||
led.stopAnimation()
|
||||
basic.clearScreen()
|
||||
if (index < arrayWords.length - 1) {
|
||||
index += 1
|
||||
} else {
|
||||
game.gameOver()
|
||||
}
|
||||
})
|
||||
arrayWords = ["cat", "guitar", "flashlight", "cupcake", "tree", "frisbee"]
|
||||
index = 0
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. . . # .
|
||||
. . # # .
|
||||
. . . . .
|
||||
. . # . .
|
||||
`)
|
||||
. # # # .
|
||||
. . . # .
|
||||
. . # # .
|
||||
. . . . .
|
||||
. . # . .`)
|
||||
basic.pause(100)
|
||||
basic.showNumber(3)
|
||||
basic.pause(100)
|
||||
|
@ -316,3 +316,7 @@ radio.onDataPacketReceived(({ receivedNumber }) => {
|
||||
radio.setGroup(1)
|
||||
basic.showString("Morse Code")
|
||||
```
|
||||
|
||||
```package
|
||||
radio
|
||||
```
|
@ -130,3 +130,7 @@ Have students write a reflection of about 150–300 words, addressing the follow
|
||||
**3 =** Reflection piece lacks 1 of the required elements.<br/>
|
||||
**2 =** Reflection piece lacks 2 of the required elements.<br/>
|
||||
**1 =** Reflection piece lacks 3 of the required elements.
|
||||
|
||||
```package
|
||||
radio
|
||||
```
|
@ -10,7 +10,7 @@ Tell the students that they will be creating a program that will act as a scorek
|
||||
|
||||
Creating and naming variables: Lead the students to create meaningful names for their variables.
|
||||
* What would be a unique and clear name for the variable that will keep track of the number of times Player A wins?
|
||||
* Student suggestions may be: ‘PAW’, PlayerA’, ‘AButtonPress’, ‘AButtonCount’, ‘PlayerAWins’...
|
||||
* Student suggestions may be: ``PAW``, ``PlayerA``, ``AButtonPress``, ``AButtonCount``, ``PlayerAWins``...
|
||||
* Discuss why (or why not) different suggestions make clear what value the variable will hold. In general, variable names should clearly describe what type of information they hold.
|
||||
|
||||
In MakeCode, from the Variables menu, make and name these three variables: `PlayerAWins`, `PlayerBWins`, `PlayersTie`.
|
||||
@ -62,13 +62,13 @@ let PlayerBWins = 0
|
||||
let PlayersTie = 0
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
PlayerAWins += 1
|
||||
PlayerAWins += 1
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
PlayerBWins += 1
|
||||
PlayerBWins += 1
|
||||
})
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
PlayersTie += 1
|
||||
PlayersTie += 1
|
||||
})
|
||||
```
|
||||
## User feedback
|
||||
@ -90,37 +90,37 @@ let PlayerBWins = 0
|
||||
let PlayersTie = 0
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
PlayerAWins += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # . # .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
PlayerAWins += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # . # .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
PlayerBWins += 1
|
||||
basic.showLeds(`
|
||||
. # # . .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
PlayerBWins += 1
|
||||
basic.showLeds(`
|
||||
. # # . .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
PlayersTie += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
PlayersTie += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
})
|
||||
```
|
||||
Notice that we added a ‘clear screen’ block after showing ‘A’, ‘B’, or ‘T’.
|
||||
@ -138,61 +138,61 @@ let PlayersTie = 0
|
||||
let PlayerBWins = 0
|
||||
let PlayerAWins = 0
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
PlayerAWins += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # . # .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
PlayerAWins += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # . # .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
PlayerBWins += 1
|
||||
basic.showLeds(`
|
||||
. # # . .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
PlayerBWins += 1
|
||||
basic.showLeds(`
|
||||
. # # . .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
PlayersTie += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
PlayersTie += 1
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.showString("Wins:")
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # . # .
|
||||
`)
|
||||
basic.showNumber(PlayerAWins)
|
||||
basic.pause(1000)
|
||||
basic.showLeds(`
|
||||
. # # . .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # . .
|
||||
`)
|
||||
basic.showNumber(PlayerBWins)
|
||||
basic.pause(1000)
|
||||
basic.showString("Ties:")
|
||||
basic.showNumber(PlayersTie)
|
||||
basic.pause(1000)
|
||||
basic.showString("Wins:")
|
||||
basic.showLeds(`
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # . # .
|
||||
`)
|
||||
basic.showNumber(PlayerAWins)
|
||||
basic.pause(1000)
|
||||
basic.showLeds(`
|
||||
. # # . .
|
||||
. # . # .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # . .
|
||||
`)
|
||||
basic.showNumber(PlayerBWins)
|
||||
basic.pause(1000)
|
||||
basic.showString("Ties:")
|
||||
basic.showNumber(PlayersTie)
|
||||
basic.pause(1000)
|
||||
basic.clearScreen()
|
||||
})
|
||||
PlayerAWins = 0
|
||||
@ -228,8 +228,8 @@ let PlayerBWins = 0
|
||||
let PlayerAWins = 0
|
||||
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.showString("Total rounds played:")
|
||||
basic.showNumber(PlayerAWins + PlayerBWins + PlayersTie)
|
||||
basic.showString("Total rounds played:")
|
||||
basic.showNumber(PlayerAWins + PlayerBWins + PlayersTie)
|
||||
})
|
||||
```
|
||||
* Save, download, and try the program again to make sure that it runs correctly and displays the correct numbers for each variable.
|
||||
|
@ -130,3 +130,7 @@ basic.forever(() => {
|
||||
radio.setTransmitPower(1)
|
||||
radio.setGroup(12)
|
||||
```
|
||||
|
||||
```package
|
||||
radio
|
||||
```
|
@ -1,8 +1,6 @@
|
||||
# Code
|
||||
### @description code to make the Reaction Time interactive
|
||||
|
||||
![](/static/mb/courses/stem/reaction_time_complete.jpg)
|
||||
|
||||
This lesson uses the @boardname@ to measure the reaction time of a student by completing a circuit on a board. The student will be measuring his/her reaction time in an undistracted environment and a distracted environment.
|
||||
|
||||
Connect each piece of foil to the appropriate pin on the @boardname@.
|
||||
|
@ -221,3 +221,7 @@ players = [0]
|
||||
radio.setGroup(10)
|
||||
radio.setTransmitSerialNumber(true)
|
||||
```
|
||||
|
||||
```package
|
||||
radio
|
||||
```
|
Loading…
Reference in New Issue
Block a user