I saw one and had to have it, but didn't have any real idea about what to do with it. I still don't, but follow me on a journey of discovery as I learn to program it, and find games to play with it!
The first thing I wanted to do was to write a basic C++ (my language of choice for the moment) console app that interfaces with the card. I've never written any sort of interface like this before - all my previous programming experience has been scientific & numerical. This involved learning how to reference an external DLL, via a library and a header file.
I'm using Visual Studio 2008 Pro edition, set up for C++, all the experiences I document herein relate to this setup, and I can't comment on any other way of doing things.
The requirement of the first program is simple - make the board respond! It has LED's to indicate the status of the outputs, so for now, the goal is to control these.
The resource file that came with the board contains three important files:
- K8055D_C.h
- K8055D_C.lib
- K8055D_C.dll
From here on out, it's straight forward. The first program I wrote flashes all the LEDs on and off three times:
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>#include <iostream>
#include <time.h>
#include "K8055D_C.h"
using namespace std;
int main(void) {
OpenDevice(0); // select device #0
// Flashing
for(int a=0;a<3;a++){
SetAllDigital(); // set all digital outputs to on
Sleep(1000); // wait one second
ClearAllDigital(); // set all digital outputs to off
Sleep(1000); // wait one second
}
CloseDevice(); // close device
return 0;
}
</code></pre>
Job jobbed! Next, I'll look at setting individual LEDs, and the analogue outputs.
No comments:
Post a Comment