quarc_host_keyboard_demo.mdl
Open this model

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

quarc_host_keyboard_demo

QUARC Host Keyboard Demo

This example demonstrates how to use the Host Keyboard block from the QUARC Targets library to obtain the state of various keyboard keys. For details of this block, please refer to the Host Keyboard block reference page in the QUARC documentation.

Host Keyboard Demo Simulink Diagram

Configuring the Demonstration

To set up the demonstration, double-click on the Host Keyboard blocks and choose which keys' states should be monitored. Select a key in the list and choose Edit, or double-click on the key in the list, to change the key. Press Add to add another key to the list. You can change the order of the keys in the output vector by using the Up and Down buttons, or remove keys using the Delete button.

When selecting a key, you can choose among a list of key categories with the Category drop-down list. Each category contains a list of keys found in the Key name drop-down list. Choose the desired key for each of the blocks. For most keys, you can also click in the "Or press key" field and then just press the desired key.

Demonstration

Select Build from the QUARC menu of the diagram, or press Ctrl+B while the diagram is the active window. A great deal of output will appear in the Diagnostic Viewer about the progress of the build. If you cannot see the Diagnostic Viewer, you can open it by selecting View/Diagnostic Viewer from the menu of the diagram, or clicking on the View Diagnostics hyperlink at the bottom of the diagram. If you have MATLAB R2013b or earlier then the output will appear in the MATLAB Command Window.

Click on the Connect to Target button or select Connect to Target from the Simulation menu of the diagram to connect to the model.

Start the model by clicking on the Run button or selecting Run from the Simulation menu of the diagram. The Start item of the QUARC menu may also be used to both connect and start the model in one operation.

In this demonstration, we monitor state of three keys: the A key, Tab key and Up Arrow key. By pressing each one of these keys, its value changes on the "Keys" display from zero to 1.

Click on the Stop button or select Stop from the Simulation menu of the diagram to stop the model. The Stop item of the QUARC menu may also be used.

Running the example on a different target

To run the example on a different target, refer to the instructions on the Running QUARC Examples on Remote Targets page.