//JSumo.com
//XLine Digital Sensor Board Test Code.
#define s0 3 // Sensor Selection pins.
#define s1 4
#define s2 5
#define s3 6
#define Sens 2 // Digital input pin.
int value;
double j=0.1;
void setup() {
pinMode(s0, OUTPUT); // 4 Selection pins are output.
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
Serial.begin(2000000);
}
void loop() { // at main loop function we use for loop and make each sensor reading.
for (int i=0; i <= 15; i++){ // Total 16 loop inside for statement.
if (i == 0)
{
digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 1)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 2)
{
digitalWrite(s0, LOW);
digitalWrite(s1, HIGH);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 3)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, HIGH);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 4)
{
digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, HIGH);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 5)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, LOW);
digitalWrite(s2, HIGH);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 6)
{
digitalWrite(s0, LOW);
digitalWrite(s1, HIGH);
digitalWrite(s2, HIGH);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 7)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, HIGH);
digitalWrite(s2, HIGH);
digitalWrite(s3, LOW);
delay(j);
value=digitalRead(Sens);
}
else if (i == 8)
{
digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
else if (i == 9)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
else if (i == 10)
{
digitalWrite(s0, LOW);
digitalWrite(s1, HIGH);
digitalWrite(s2, LOW);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
else if (i == 11)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, HIGH);
digitalWrite(s2, LOW);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
else if (i == 12)
{
digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, HIGH);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
else if (i == 13)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, LOW);
digitalWrite(s2, HIGH);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
else if (i == 14)
{
digitalWrite(s0, LOW);
digitalWrite(s1, HIGH);
digitalWrite(s2, HIGH);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
else if (i == 15)
{
digitalWrite(s0, HIGH);
digitalWrite(s1, HIGH);
digitalWrite(s2, HIGH);
digitalWrite(s3, HIGH);
delay(j);
value=digitalRead(Sens);
}
Serial.print(value);
Serial.print(' ');
}
Serial.print(millis());
Serial.println();
// After 16 for loop we go to 2nd line.
}