We can write the program to control the simulator in a variety of languages. Using the gpio program we can do it in a simple shell script (or even call it from languages such as php, perl, etc.) and using the wiringPi library then we can call it from C or C++.
As a bit of an exercise, I have written 2 versions – one using the standard BASH and the other in C. You can get the source code here:
The bash code (tuxx.sh) will run directly, but to make the C program run, we first need to compile it, then run it as root via the sudo command.
mkdir ~/tuxx cd ~/tuxx
To get and run the Bash version:
wget http://project-downloads.drogon.net/files/gpioExamples/tuxx.sh chmod +x tuxx.sh ./tuxx.sh
To get and run the C version:
wget http://project-downloads.drogon.net/files/gpioExamples/tuxx.c cc -o tuxx -Wall -I/usr/local/include -L/usr/local/lib tuxx.c -lwiringPi sudo ./tuxx
to get the latest via GIT:
git clone git://git.drogon.net/gpioExamples cd gpioExamples/tuxx make sudo ./tuxx
Do examine the code (both the C and Bash versions) to understand how they work and how to adapt them for your own projects