# Reaction tester problem.

Hi to everyone! I need help to create a code to measure how long it takes to swicht off two leds that light on at the same time, using two buttons . To resume, two leds light on simultaneously. I have two buttons each corresponding to a specific led. I have to switch off both the leds hitting the corresponding buttons without any priority and calculate how long it takes. Anyone could help me, please? If both leds are not hit whithin a fixed time interval I would like to make a specific action. How could I solve also this problem? I have 8 leds and 8 buttons each corresponding to a led. So led1/button1, led2/button2…… Two of these 8 leds (chosen randomly) have to light on simultaneously. I have an interval of time to hit both without any priority ( I can decide which first). The results can be: - Both targets hit within the assigned time whatever the order is: WIN; - One hit correctly, the other not (the button did not correspond to the led: (LOOSE); - Both hit wrongly; (LOOSE); - Only one hit or none within the assigned time: (OUTOFTIME).

put the button pin #s in an array

you presumably have code to turn on 2 out of the 8 LEDs. capture the time (milliis()) both LEDs are turned on

scan each button in the array, checking for a change in state and capture a timestamp (millis()) in an array for each button and count the # of buttons pressed. No need to debounce.

when two buttons have been pressed after the LEDs are turned on, compare the button times to the LED times and decide what to do

Hi gcjr! Thank you for your reply! What do you mean with "compare the button times with the led times"? When two leds turn on, I have to push two buttons. Each button is related to its led. My code can determine if any button has been pressed or not and also if they have been pressed whitin a preset time interval. What I am not able to do is to understand if the button have been pressed correctly. My code cannot understand if I have pressed wrongly button2 for led1 and button1 for led2. The two buttons have been pressed but I would like to determine if they have been press correctly led1 button1 and led 2 button 2.