Write a simple INPUT program for KMK USB 13IO Card with Microsoft Visual C# Express 2008.

We are going to write a program to read the tact switches status, display it and do some responses on the computer screen. Please refer to KMK USB 13IO Card manual for detail operations.


Step 1 - 2 need to do once on your computer. Just skip steps 1 - 2 if you have done it already.

Step 1 Install Visual C# 2008 Express.

Step 2 USB Driver installation.

Step 3 Install KMK USB 5I8O OCX for KMK USB 13IO card.

Step 4 Load KMK USB 5I8O OCX into C# 2008 Express.


Step 5


Make sure you have attached the IO card to the PC and the OCX is on the form. Then you should see the serial number of the card on the status window as below;


Step 6


We are going to write the code for automatically connecting the IO card while the program is started. Double click on the empty space of the form to enter into the code page. Type the code as below between the blankets of the Form1_Load event section.

Note: All commands in C# are case sensitive and each line should be ended with ; mark.


Step 7


We need a timer to scan the tact switches status from time to time. This process is known as 'Polling'. From the tool box choose 'Timer' and drag it to the form. Change the property Enable to True.


Step 8


Choose a TextBox from the Toolbox and drag it to the form.


Step 9


Double click the Timer and type the code inside the blankets of the timer1_Tick as below;


Step 10


Now Run the program by clicking 'Start Debugging' button on the tool bar or press F5 and observe the content of the textbox while pressing the tact switches of the IO card.


Note: You can connect NO(Normal Open) or NC(Normal Close) Switches such as Puch Buttons, Magnetic Switches, Reed Switches, etc to the IO Card. The above program is essential for creating computer games controlled with external hardware switches.