diff --git a/docs/projects/reaction-time/code.md b/docs/projects/reaction-time/code.md index f4aca4ae..74eab3f7 100644 --- a/docs/projects/reaction-time/code.md +++ b/docs/projects/reaction-time/code.md @@ -1,30 +1,27 @@ # Code ## @description code to make the Reaction Time interactive -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. +This lesson uses the @boardname@ to measure a student's reaction time in completing a circuit path on a cardboard pad. The student's reaction time is measured in both a distracted and an undistracted environment. Connect each piece of foil to the appropriate pin on the @boardname@. -## ~ hint +**Note:** For the experiment we are **not** using the **P2** pin as shown in the video. -For the experiment we will **not** be utilizing the ``P2`` pin. +Test the reaction pad by putting one hand on the ground pin (**GND**) and one hand on the **P0** pin. This completes the circuit and starts the timer on the @boardname@ after an initial 3 second count down. -## ~ - -Test the apparatus by putting one hand on the ground pin and one hand on the ``P0`` pin. This will complete the circuit and start the timer on the @boardname@ after a 3 second count down. - -Once the timer starts, wait for the LED screen to light up and then press the Ground foil with one hand and and the ``P1`` with the other. This will connect the circuit and shut off the timer. - -The @boardname@ will then read off the time in milliseconds from when the timer starts and the circuit is completed. +Once the timer starts, wait for the LED screen to light up and then press the **GND** foil with one hand and and the **P1** foil with the other. This completes the circuit and shuts off the timer. +The @boardname@ then reads the time, in milliseconds, between timer start and closed circuit. ## Step 1: Variables -In order for **Reaction Time** to follow the rules for determining the player's reaction speed, we need to add variables that will store data. Then we will assign (set) the value of the variables. We want to name the four (4) variables as follows: “start”, “end”, “false_start”, and “running”. Set the value of the variables, “start” and “end” to 0. Then set the value of the variable “false_start” and “running” to false. Modify your code so that your code looks like this. +In order for **Reaction Time** to track the speed of a a player's reaction, we need to add variables to keep some data. We initialize (assign, or set) the variables to some starting values. The variables needed are: `start`, `end`, `false_start`, and `running`. Set the values of variables `start` and `end` to `0`, which means no time elapsed. Then set the value of the variables `false_start` and `running` to `false` to say we haven't started yet. -In the code below: -- the reaction time experiment will start and end at specific times based on the player's reaction. -- the code will keep track of when the experiment is running as well as when the player has a false start in the experiment. +So, our tracking variables do this: +- the reaction time experiment starts and ends at specific times based on the player's reaction. +- the code tracks when the experiment is running as well as when the player has a false start. + +Add these variables to your code: ```blocks let start = 0 @@ -35,13 +32,13 @@ running = false false_start = false end = 0 start = 0 - - ``` ## Step 2: On pin pressed -We want to register an event handler that will execute whenever the user holds the GND pin with one hand, and presses pin 0 or pin with the other hand, thus completing a circuit. When you run a script with this function in a web browser, click pins 0 or 1 in the simulator. The game will start on ``P0`` and the ``P1`` will detect when the player visualizes a single LED on the screen. Modify your code so that your code looks like this. +We need to register event handlers that will execute whenever the user presses down on the **GND** pin with one hand, and presses pin **P0** or **P1** with the other hand, which completes the circuit. Our event handlers are two ``||input:on pin pressed||`` blocks, one for **P0** and the other for **P1**. + +Add the ``||input:on pin pressed||`` blocks to your code: ```blocks let start = 0 @@ -58,11 +55,11 @@ running = false false_start = false end = 0 start = 0 - ``` + ## Step 3: Countdown timer -We want to code the countdown timer that will be displayed on pin pressed 0. We will insert three show number blocks to visually display the countdown: ``3 2 1``. Then we want to add a ``|basic|`` block clear screen to clear the numbers from the screen. Modify your code so that your code looks like this: +We need a countdown timer that shows the seconds counting down when pin **P0** is pressed. Let's insert three ``||basic:show number||`` blocks to visually display the countdown sequence: **3**...**2**...**1**. Next, add a ``||basic:clear screen||`` block to clear the numbers from the screen. Modify your code so that it looks like this: ```blocks let start = 0 @@ -82,14 +79,13 @@ running = false false_start = false end = 0 start = 0 - ``` ## Step 4: Boolean -We want to set variables, running and set false start to false. This occurs on pin 0 pressed. Those blocks represent the true and false Boolean values. A Boolean has one of two possible values: true; false. +Now we'll set the variables `running` and `false_start` to `false` in the **P0** event. -Modify your code so that your code looks like this: +Add the ``||variables:set to||`` blocks for `running` and `false_start` like like this: ```blocks let start = 0 @@ -111,13 +107,11 @@ running = false false_start = false end = 0 start = 0 - ``` - ## Step 5: Begin reaction time randomly -We want to introduce the reaction time experiment if there is not a false start on pin 0 pressed. Reaction time will randomly plot a LED on the x and y coordinates. Modify your code so that your code looks like this: +Let's add a random starting time after pin **p0** is pressed. Include the ``||math:random||`` block in a ``||basic:pause||`` at the bottom of the event block like this: ```blocks let start = 0 @@ -140,12 +134,11 @@ running = false false_start = false end = 0 start = 0 - ``` ## Step 6: Plot LED on X, Y coordinates randomly -We want to introduce the reaction time experiment if there is not a false start. Reaction time will randomly plot a LED on the x and y coordinates. Modify your code so that your code looks like this: +The reaction time will begin if no false start is detected (pin **P0** pressed at the wrong time). When the reaction time starts, a LED is randomly plotted at some the x and y coordinate on the display. Add in the blocks contatined in the ``||logic:if then||`` that show the reaction time: ```blocks let start = 0 @@ -177,13 +170,13 @@ end = 0 start = 0 ``` - ## Step 7: Display feedback to reaction -We want to add code to detect when the player presses the Ground foil with one hand and and the P1 with the other. This code will connect the circuit and shut off the timer. We will add code to have the @boardname@ read off the time in milliseconds from when the timer starts and the circuit is completed. This code also detects if there is a correct reaction or false start on pin 1 pressed. +Add some code to detect when the player presses the **GND** foil with one hand and the **P1** pin with the other. This code detects the circuit connection and shuts off the timer. Also, add code to have the @boardname@ read the time in milliseconds from when the timer starts and the circuit is completed. This code also detects if there is a correct reaction or false start if pin **P1** is pressed. -We want to display one of two images on pin 1 pressed. The first image displays if the player correctly completes the circuit between GND and P1. A correct reaction occurs to complete the circuit on pin 1 pressed after the randomly generated LED appears on the screen. The seconde image displays if the player completes a circuit between GND and P1 on a false start. A false start occurs when the player completes a circuit on pin 1 pressed before the LED randomly appears on the x, y coordinates. Modify your code so that your code looks like this: +Let's display one of two images if pin **P1** is pressed. The first image displays if the player correctly completes the circuit between **GND** and **P1**. This means that a correct reaction occurred to complete the circuit with pin **P1** pressed after the randomly generated LED appears. +The second image displays if the player completes a circuit between **GND** and **P1** but on a false start. A false start is detected if the player completes a circuit if pin **P1** is pressed before the LED randomly appears at its random x, y coordinate. Modify the code to include the actions for the pin **P1** event: ```blocks let start = 0 @@ -234,16 +227,14 @@ running = false false_start = false end = 0 start = 0 - ``` ## Extension -After the students have finished their experiments. Have them play the game with a friend (using the P2 pin) and have competitons to see who is the quickest on the draw. +After the students have finished their experiments. Have them play the game with a friend (using the **P2** pin) and have some contests to see who is the quickest on the draw. You can find the code for this below: - ```blocks let start = 0 let end = 0 @@ -313,5 +304,4 @@ input.onPinPressed(TouchPin.P2, () => { `) } }) - ``` diff --git a/docs/projects/reaction-time/make.md b/docs/projects/reaction-time/make.md index 33a6e825..91ee7961 100644 --- a/docs/projects/reaction-time/make.md +++ b/docs/projects/reaction-time/make.md @@ -4,8 +4,12 @@ https://youtu.be/DgJ-S0q0EMs +## Make the reaction pad + * Fold the foil squares and place them around the cardboard. -* Connect each piece of foil to the appropriate pin on the Micro:bit. Note: For the experiment we will not be utilizing the P2 pin +* Connect each piece of foil to the appropriate pin on the @boardname@. + +**Note:** Although the video shows a connection to the **P2** pin, it isn't used in this experiment. That's it!