import com.LabJack.LabJackJNI; import com.LabJack.LabJackException; /** * This program demonstrates the use of com.LabJack.LabJackJNI.EAnalogOut(). */ public class EDigitalIn { static public void main( String args[] ) { System.out.println( "EDigitalIn() Example" ); int idnum[] = new int[ 1 ]; idnum[ 0 ] = -1; // use first LabJack found int demo = 1; // DEMO mode, set to 0 if LabJack connected int readd; int state[] = new int[ 1 ]; // // read state of IO0-IO3 digial inputs // System.out.print( " " ); readd = 0; // channel number refers to IO0-IO3 inputs for( int channel = 0; channel < 4; channel++ ) { int errCode = LabJackJNI.EDigitalIn( idnum, demo, channel, readd, state ); if( errCode != 0 ) { System.out.println( "error: " + errCode ); } else { System.out.print( state[ 0 ] == 0 ? "0" : "1" ); } } System.out.println(); // // read state of D0-D15 digial inputs // System.out.print( " " ); readd = 1; // channel number refers to D0-D15 inputs for( int channel = 0; channel < 16; channel++ ) { int errCode = LabJackJNI.EDigitalIn( idnum, demo, channel, readd, state ); if( errCode != 0 ) { System.out.println( "error: " + errCode ); } else { System.out.print( state[ 0 ] == 0 ? "0" : "1" ); } } System.out.println(); } }