From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Reaction Test Game using Queues and Color Box

Code and Documents

Attachment

Download All

Overview

This is my Reaction Test Game using Producer-Consumer architecture. The example uses queues and records the time using the Tick Count (ms) function. The program is fairly basic but allows the user to see their reaction time.


Description

Firstly the program initialises the Start Button and Colour box. After this a queue is created, containing a cluster of two elements, the next state and the tick count (ms).

The game starts when you click the start button. At this point, the next state is added, and a random time is generated (1-5 seconds).

The state machine then waits this random time, before chaning the colour of the colour box. Once the colour has been changed, the tick count is recorded.

As soon as the space bar is pressed, a new event (and state is generated) and the tick count is recorded again.

The program then changes to the "Results" state where the total time in ms is calculated (Final tickcount - Start tick count). This is then presented to the player.

Reaction.PNG
Steps to Implement or Execute Code

1) Download the project

2) Open React_Main.vi

3) Run the VI.

4) Instructions are shown in dialog box

Requirements

Software

LabVIEW 8.6 or newer


Hardware

Keyboard!

__________________________
Aidan H

Applications Engineer
National Instruments UK & Ireland

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors