Write a simple INPUT & OUTPUT program for KMK USB 13IO Card with Microsoft Visual C# Express 2008.
We are going to write a program to control the leds according to the input status of the tact switches. 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
Enter the code below and we can finish the input and output code easily.
Step 9
Now Run the program by clicking 'Start Debugging' button on the tool bar or press F5 and observe Leds while pressing the tact switches of the IO card.
Note: You can connect DC 6V~9V devices to the board such as DC motors, light bulbs etc. and connect Push buttons, Magnetic switches,etc to the IO card. Remember to apply external DC 6V-9V power to it.