updated lessons

This commit is contained in:
Michael Elliot Braun
2016-03-30 16:43:56 -07:00
parent 8ede130a95
commit 612142a292
5 changed files with 14 additions and 16 deletions

View File

@ -1,133 +0,0 @@
# speed button lesson
code a speed game by declaring Booleans on the BBC micro:bit #if #string #var #data #docs
### @video td/videos/speed-button-3
## Topic
Running Time
## Quick Links
* [tutorial](/microbit/lessons/speed-button/tutorial)
* [quiz](/microbit/lessons/speed-button/quiz)
* [quiz answers](/microbit/lessons/speed-button/quiz-answers)
* [challenges](/microbit/lessons/speed-button/challenges)
## Class
Year 7
## Prior learning/place of lesson in scheme of work
Learn how to declare a **Boolean** variable, `var t:= true` `var f:=false` for one of two possible values: true or false. We will be learning how to declare Boolean variables using global variables, if (conditionals), input on button pressed, input running time, as well as simple commands, such as input on button pressed, and show string.
## What the teacher needs to know
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
* Command: An instruction for the computer to execute, written in a particular programming language.
* Data: A structured set of numbers, possibly representing digitised text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
* Decomposing: The process through which problems or systems are broken down into their component parts, each of which may then be considered separately.
* Hardware: The physical systems and components of digital devices; see also software.
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
* Program: A stored set of instructions encoded in a language understood by the computer that does some form of computation, processing input and/or stored data to generate output.
* Repetition: Executing a section of computer code a number of times as part of the program.
* Script: A computer program typically executed one line at a time through an interpreter, such as the instructions for a Scratch character.
* Selection: A programming construct in which one section of code or another is executed depending on whether a particular condition is met.
* Sequence: To place program instructions in order, with each executed one after the other.
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
* Variables: A way in which computer programs can store, retrieve or change data, such as a score, the time left, or the users name.
**QuickStart Computing Glossary
## Documentation
* **running time** : [read more...](/microbit/reference/input/running-time)
* **global variable** : [read more...](/microbit/js/data)
* **Boolean** : [read more...](/microbit/reference/types/boolean)
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
* **if** : [read more...](/microbit/reference/logic/if)
* **show string** : [read more...](/microbit/reference/basic/show-string)
## Resources
* Activity: [tutorial](/microbit/lessons/speed-button/tutorial)
* Activity: [quiz](/microbit/lessons/speed-button/quiz)
* Extended Activity: [challenges](/microbit/lessons/speed-button/challenges)
## Objectives
* learn how to get the number of milliseconds elapsed since the script began. 1,000 milliseconds = 1 second
* learn how to create a global variable to store data so that you can use it later in your code and will be accessible across functions and in nested code blocks
* learn how to create a Boolean with one of two possible values: true or false
* learn how to run code when an input button is pressed
* learn how to conditionally run code depending on whether a condition is true or not
* learn how to show a string on the LED screen one character at a time
## Links to the National Curriculum Programmes of Study for Computing
## Progression Pathways / Computational Thinking Framework
#### Algorithms
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
* Uses diagrams to express solutions.(AB)
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
* Designs solutions by decomposing a problem and creates a sub-solution for each of these parts. (DE) (AL) (AB)
* Recognises that different algorithms exist for the same problem (AL) (GE)
* Represents solutions using a structured notation (AL) (AB)
#### Programming & Development
* Creates programs that implement algorithms to achieve given goals (AL)
* Declares and assigns variables(AB)
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
* Selects the appropriate data types(AL) (AB
#### Data & Data Representation
* Uses filters or can perform single criteria searches for information.(AL)
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
* Defines data types: real numbers and Boolean (AB)
#### Hardware & Processing
* Knows that computers collect data from various input devices, including sensors and application software (AB)
#### Communication Networks
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
#### Information Technology
* Collects, organizes, and presents data and information in digital content (AB)
* Makes appropriate improvements to solutions based on feedback received, and can comment on the success of the solution (EV)
* Recognises ethical issues surrounding the application of information technology beyond school.
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
## Activity
* time: 20 min.
* [tutorial](/microbit/lessons/speed-button/tutorial)
* [quiz](/microbit/lessons/speed-button/quiz)
* assessment opportunities: forever, plot, pause, clear screen
## Extended Activity
* time: 20 min.
* [challenges](/microbit/lessons/speed-button/challenges)
* assessment opportunities: loops, plot, pause, clear screen
## Homework
* Extended Activity: [challenges](/microbit/lessons/speed-button/challenges)
## Intended follow on
Publish script to the classroom.

View File

@ -1,99 +0,0 @@
# speed button challenges
Coding challenges for the speed button tutorial. #docs
## Before we get started
Complete the following guided tutorial:
* [tutorial](/microbit/lessons/speed-button/tutorial)
At the end of the tutorial, click `keep editing`. Your code should look like this:
```
let counter = 0
let fastPress = false
input.onButtonPressed(Button.A, () => {
counter = counter + 1
})
```
### Challenge 1
We need to know when the user has hit button `A` 15 times. The user wins when he/she is able to accomplish this in less than 5000 milliseconds (5 seconds). We can check for both conditions by using an `and` operator. When using an `and` operator, both conditions need to be true in order for the condition to be true.
```
let counter1 = 0
let fastPress1 = false
input.onButtonPressed(Button.A, () => {
counter1 = counter1 + 1
if (counter1 == 15 && input.runningTime() < 5000) {
}
})
```
Next, if the user has won, let's set our boolean to true. This indicates that he or she has won.
```
let counter2 = 0
let fastPress2 = false
input.onButtonPressed(Button.A, () => {
counter2 = counter2 + 1
if (counter2 == 15 && input.runningTime() < 5000) {
fastPress2 = true // ***
}
})
```
### Challenge 2
We want to set `fastPress` to false if the user was too slow. To do so, we need another condition to see if the user took more than 5000 milliseconds (5 seconds). In the `if` statement, set `fastPress` to false.
```
let counter3 = 0
let fastPress3 = false
input.onButtonPressed(Button.A, () => {
counter3 = counter3 + 1
if (counter3 == 15 && input.runningTime() < 5000) {
fastPress3 = true
}
if (counter3 == 15 && input.runningTime() > 4999) {
fastPress3 = false // ***
}
})
```
### Challenge 3
### @video td/videos/speed-button-3
Now let's display if the user won or lost. To do so, we need to check the status of `fastPress` when the game is finished, and then show the correct message.
```
let counter4 = 0
let fastPress4 = false
input.onButtonPressed(Button.A, () => {
counter4 = counter4 + 1
if (counter4 == 15 && input.runningTime() < 5000) {
fastPress4 = true
}
if (counter4 == 15 && input.runningTime() > 4999) {
fastPress4 = false
}
if (counter4 == 15 && fastPress4) {
basic.showString("YOU WIN!", 150) // ***
}
if (counter4 == 15 && ! fastPress4) {
basic.showString("TOO SLOW!", 150) // ***
}
})
```
* Click the `run` button to see if the code runs properly.
### Challenge 4
### @video td/videos/speed-button-4
Modify the code to change the difficulty level. Increasing the time will make it easier, while decreasing the time will make it harder. For example, changing the 5000 milliseconds to 6000 milliseconds will make the difficulty easier.

View File

@ -1,50 +0,0 @@
# speed button quiz answers
counter that keeps track of how many times button "A" has been pressed #LED #screen #variables #docs #input
This is the answer key for the [speed button quiz](/microbit/lessons/speed-button/quiz).
## 1. What is a variable?
<br/>
A variable that is available throughout your main function.
## 2. If the rectangle below represents the BBC micro:bit, shade the area that shows the value of the variable count.
```
let count = 0
```
![](/static/mb/lessons/speed-button-0.png)
## 3. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed after two button presses on Button A. Explain why that particular area is shaded.
```
let count_ = 0
input.onButtonPressed(Button.A, () => {
count_ = count_ + 1
basic.showNumber(count_, 100)
})
```
<br/>
![](/static/mb/lessons/speed-button-1.png)
After two button presses, **count** will be equal to 2.
## 5. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed after five button presses on Button A. Explain why that particular area is shaded.
```
count_ = 0
input.onButtonPressed(Button.A, () => {
count_ = count_ + 1
basic.showNumber(count_, 100)
})
```
![](/static/mb/lessons/speed-button-2.png)
After five button presses, **count** will be equal to 5.

View File

@ -1,50 +0,0 @@
# speed button quiz
counter that keeps track of how many times button "A" has been pressed #LED #screen #variables #docs #input
## Name
## Directions
Use this activity document to guide your work in the [speed button tutorial](/microbit/lessons/speed-button/tutorial).
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. What is a variable?
## 2. Draw which LEDs show the number being stored as a global variable called count
```
let count = 0
```
![](/static/mb/empty-microbit.png)
## 3. Draw which LED is ON after running this code and pressing Button A twice. Explain why you chose to draw that number
```
let count_ = 0
input.onButtonPressed(Button.A, () => {
count_ = count_ + 1
basic.showNumber(count_, 100)
})
```
![](/static/mb/empty-microbit.png)
<br/>
## 4. Draw which LED is ON after running this code and pressing Button A five times. Explain why you chose to draw that number.
```
count_ = 0
input.onButtonPressed(Button.A, () => {
count_ = count_ + 1
basic.showNumber(count_, 100)
})
```
![](/static/mb/empty-microbit.png)
<br/>