// WiringPi piface program IN, OUT, PULL // Compile: gcc -Wall wiringpi_piface_test1.c -o wiringpi_piface_test1 -lwiringPi -lwiringPiDev #include "wpi_test.h" #include // Use 200 as the pin-base for the PiFace board, and change all pins // for the LED and relays const int PIFACE = 200; //Mapped wiringpi IO address const int defaultsleep = 200000; // 200 ms void ReadUntilTimeout(int GPIO, int expect, int timeoutSec) { const int intervaluS = 250000; //250ms int in; const char* strexpect = expect ? "HIGH" : "LOW"; for(int loop=0, end=(timeoutSec*1000000/intervaluS); loop test not possible } //6 & 7 connected from relais NO (normaly open) to in -> test possible delayMicroseconds(defaultsleep); pullUpDnControl (PIFACE + IN, PUD_UP) ; ReadUntilTimeout(PIFACE + IN, HIGH, 2) ; pullUpDnControl (PIFACE + IN, PUD_DOWN) ; // cool down very slowly, connect 680 kOhm pull down resistor to make ist faster ReadUntilTimeout(PIFACE + IN, LOW, 60) ; pullUpDnControl (PIFACE + IN, PUD_UP) ; // finally up ReadUntilTimeout(PIFACE + IN, HIGH, 2) ; } return UnitTestState(); }