LED display, Buzzer sound, Conditional statements, Logical operators, Timers, Functions (extension)
This activity teaches the basics of relatively accurate reaction time measuring. Using a computer program to measure reactions times are much more accurate than using manual methods like a stopwatch. Accurate readings are vital in many instances, where one such example is in professional sprinting races; reaction times are required to be accurate to 3 decimal places.
In this activity, you are going to use the Finch to measure a person’s visual and auditory reaction time. The reaction time is the amount of time that it takes someone to respond to a stimulus. A stimulus is something that happens in the person’s environment, like a beep or a change in colour.
Visual Reaction Time
To measure the reaction time, you need to change the colour of the Finch’s beak or tail, and then measure how long it takes the user to move the Finch.
· At the beginning of the program, ask the user to place the Finch in a level position and wait until he/she has done so.
· The Finch should wait for a random number of seconds from 2-5 and then change colour.
· As soon as the Finch changes colour, measure how long it takes for the user to move the Finch out of the level position.
Auditory Reaction Time
To measure the reaction time, you will measure how long it takes the user to react by moving the Finch out of the level position once the buzz starts. The program should be similar to the one done previously for Visual Reaction Time. Remember to give the user instructions so they know what to do!
1. Use a say block to prompt the user to place the finch in a level position.
4. Use the reset timer block directly after the wait block.
6. Use a wait until block that is triggered when the Finch is not in a level position.
7. Use a say block to print out the reaction time (timer block) on the screen.
1. Import the sleep() and time() function from the time library using 'from time import sleep,time'
2. Import the random library using 'import random'.
3. Use "prompt = input('Place the Finch in a level position! When done press enter.')" to prompt the user to place the Finch in a level position. Only when the user presses enter will the program continue to run.
4. Use "sleep(random.randint(2,5))" to pause the program for a random amount of time between 2 and 5 seconds. After that, use the 'startTime = time()' statement.
5. Use a while loop that only breaks when the Finch is not in a level position. Within the while loop, set the beak and tail of the Finch to any colour of your choice (visual reaction) or play a note of your choice (auditory reaction).
6. When the loop breaks, use the endTime = time() statement. Follow that up with the bird.stopAll() function to stop the colour display or the note buzzing.
7. Use "reactiontime = endTime - startTime" to calculate the reaction time of the user in seconds.
8. Use the print() function to print the reaction time to the screen.
Write functions that use the Finch to measure a person’s auditory and visual reaction time.
Once you have a function to measure the reaction time, you should write a program that uses these functions to measure 5-10 reaction times for each type of stimulus. You should save all the reaction times in a list. Print all the reaction times to the screen and calculate and display the mean reaction time.
Hint: The sum() function may be useful.
1. Define two functions that use the Finch to measure a person’s auditory and visual reaction time respectively. These functions should return the respective reaction times using the 'return' method.
2. Use these functions to measure 5-10 reaction times for each type of stimulus, using a for loop.
3. Append all the reaction times in two seperate lists for visual and auditory reaction times throughout the loop.
4. Print all the reaction times to the screen and calculate and display the mean reaction time for each stimulus. Mean reaction time is the sum of all the reaction times divided by the total number of times. Use the sum(<enter list here>) function to calculate the total sum of the times. Use the '/' symbol to represent division.