Reaction Time Game. More...
Functions | |
| def | Lab2.count_isr (PC13) |
| Button Push ISR. More... | |
Variables | |
| Lab2.blinky = pyb.Pin(pyb.Pin.board.PA5, mode = pyb.Pin.OUT_PP) | |
| set led as blinky More... | |
| int | Lab2.blinky_status = 0 |
| Blinky Flag. More... | |
| int | Lab2.reaction_sum = 0 |
| Sum of the past reaction times. More... | |
| int | Lab2.reaction_num = 0 |
| Number of times played. More... | |
| int | Lab2.counter_status = 0 |
| Time on the counter. More... | |
| int | Lab2.random_time = 0 |
| A random time. More... | |
| int | Lab2.average_response = 0 |
| Value of Average. More... | |
| int | Lab2.state = 0 |
| Value of the state. More... | |
| Lab2.tim = pyb.Timer(2, prescaler=79, period = 0x3fffffff) | |
| Timer Object. More... | |
| Lab2.extint | |
| External Interrupt Variable. More... | |
Reaction Time Game.
Program initializes and prompts you to play a game in which you will attempt to press the blue button on our microcontroller as soon as you see the green light turn on. Once you press it, the green light will turn off and your reaction time will be presented in microseconds, and it will wait a random time period between 0 and 6 seconds to turn on again. If you do not press the green light within 1 second, it will automatically exit and the game will be over. When the user presses control-c, their average time will be presented in seconds. (That is how I understood this assignment.)
| def Lab2.count_isr | ( | PC13 | ) |
Button Push ISR.
When the user presses the PC13 button, the program will jump here. This ISR will determine if the LED was on. If so it will record the user reaction time, display that, add that time to the sum of their reaction times, and increment the number of times they have played.
| PC13 | the value of the pin to be pushed on the microcontroller |
| tuple Lab2.average_response = 0 |
Value of Average.
Average response of the user after exiting
| Lab2.blinky = pyb.Pin(pyb.Pin.board.PA5, mode = pyb.Pin.OUT_PP) |
set led as blinky
When I refer to blinky, I am refering to the LED pin on the board
| int Lab2.blinky_status = 0 |
Blinky Flag.
Always set as either 0 if blinky is off or 1 if blinky is on this will be used to let the interrupt know whether the button has been pressed appropriately or not.
| int Lab2.counter_status = 0 |
Time on the counter.
Stores the time on the counter when the user interrupted
| Lab2.extint |
| Lab2.random_time = 0 |
A random time.
Used to store a random time between 0 and 6 seconds for the LED to turn on
| int Lab2.reaction_num = 0 |
Number of times played.
Number of reaction times by the user, used to compute the average
| int Lab2.reaction_sum = 0 |
Sum of the past reaction times.
adds up the reaction times to compute the average later
| int Lab2.state = 0 |
Value of the state.
I still have 305 assembly language PTSD. I can't not use states
| Lab2.tim = pyb.Timer(2, prescaler=79, period = 0x3fffffff) |
Timer Object.
Timer object on timer 2 with a prescaler of 79 and a period of 0x3fffffff