#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.
}
#define s0 7 // Sensor Selection pins.
#define s1 6
#define s2 5
#define s3 3
#define Sens 2 // Digital input pin.
int E1 = 10;
int M1 = 12;
int E2 = 11;
int M2 = 13;
double j = 0.1;
void setup() {
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(s0, OUTPUT); // 4 Selection pins are output.
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
Serial.begin(9600);
}
void loop() { // at main loop function we use for loop and make each sensor reading.
int sensor0 = xline(s0, s1, s2, s3, j, Sens, LOW, LOW, LOW, LOW); //llll-0
int sensor1 = xline(s0, s1, s2, s3, j, Sens, HIGH, LOW, LOW, LOW); //hlll-1
int sensor2 = xline(s0, s1, s2, s3, j, Sens, LOW, HIGH, LOW, LOW); //lhll-2
int sensor3 = xline(s0, s1, s2, s3, j, Sens, HIGH, HIGH, LOW, LOW); //hhll-3
int sensor4 = xline(s0, s1, s2, s3, j, Sens, LOW, LOW, HIGH, LOW); //llhl-4
int sensor5 = xline(s0, s1, s2, s3, j, Sens, HIGH, LOW, HIGH, LOW); //hlhl-5
int sensor6 = xline(s0, s1, s2, s3, j, Sens, LOW, HIGH, HIGH, LOW); //lhhl-6
int sensor7 = xline(s0, s1, s2, s3, j, Sens, HIGH, HIGH, HIGH, LOW); //hhhl-7
int sensor8 = xline(s0, s1, s2, s3, j, Sens, LOW, LOW, LOW, HIGH); //lllh-8
int sensor9 = xline(s0, s1, s2, s3, j, Sens, HIGH, LOW, LOW, HIGH); //hllh-9
int sensor10 = xline(s0, s1, s2, s3, j, Sens, LOW, HIGH, LOW, HIGH); //lhlh-10
int sensor11 = xline(s0, s1, s2, s3, j, Sens, HIGH, HIGH, LOW, HIGH); //hhlh-11
int sensor12 = xline(s0, s1, s2, s3, j, Sens, LOW, LOW, HIGH, HIGH); //llhh-12
int sensor13 = xline(s0, s1, s2, s3, j, Sens, HIGH, LOW, HIGH, HIGH); //hlhh-13
int sensor14 = xline(s0, s1, s2, s3, j, Sens, LOW, HIGH, HIGH, HIGH); //lhhh-14
int sensor15 = xline(s0, s1, s2, s3, j, Sens, HIGH, HIGH, HIGH, HIGH); //hhhh-15
//15
if(sensor0 == 0 && sensor1 == 0 && sensor2 == 0 && sensor3 == 0 && sensor4 == 0 && sensor5 == 0 && sensor6 == 0 && sensor7 == 0 &&
sensor8 == 0 && sensor9 == 0 &&sensor10 == 0 && sensor11 == 0 && sensor12 == 0 && sensor13 == 0 && sensor14 == 0 && sensor15 == 1)
{digitalWrite(M1, HIGH); analogWrite(E1, 255); }
}
int xline(int s00, int s11, int s22, int s33, float j1, int sens1, int self, int self1, int self2, int self3) {
digitalWrite(s00, self);
digitalWrite(s11, self1);
digitalWrite(s22, self2);
digitalWrite(s33, self3);
delay(j1);
int value = digitalRead(sens1);
return value;
delay(5);
}
//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.
}