Read Arduino darts matrix

blh64:
This will report how long each of your master lines goes low, in microseconds. That may give you an idea of how often the electronics read these lines. It may give you nothing. I don't know since I don't have a dart system.

By the way - why did you swap your Master and Slave lines compared to your original post?

const int masterLines = 16; //Change here to the number of lines of your Master Layer

const int slaveLines = 4; //Change here to the number of lines of your Slave Layer
const int matrixSlave[slaveLines] = { 22, 24, 49, 47 };
// Input Pins
const int matrixMaster[masterLines] = { 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 53, 51 };
void setup() {
  Serial.begin(9600);
  Serial.println("OpenDarts"); //This line is not necessary, is just here for debug purposes

// all pins are input by default so this code is not needed
#if 0
  for (int i = 0; i < slaveLines; i++) {
    pinMode(matrixSlave[i], INPUT_PULLUP);
  }
  for (int i = 0; i < masterLines; i++) {
    pinMode(matrixMaster[i], INPUT);
    digitalWrite(matrixMaster[i], HIGH);
  }
#endif

}
unsigned long timing[masterLines];

void loop() {
  for (int i = 0; i < masterLines; i++) {
    timing[i] = measureTime(matrixMaster[i]);
  }

Serial.println( "Timing measurements in microseconds" );
  for (int i = 0; i < masterLines; i++) {
    Serial.print( "Master line ");
    Serial.print( i );
    Serial.print( ": " );
    Serial.println( timing[i] );
  }
  while (1); // loop forever
}

unsigned long measureTime( int pin ) {

const unsigned long timeout = 2 * 1000 * 1000UL;  // only wait 2 seconds, max
  unsigned long start = micros();
  // wait for pin to be high
  while( digitalRead(pin) == HIGH) {
    if( micros() - start >= timeout ) {
      return timeout;
    }
  }
  // pin has gone low, time how long it stays low
  start = micros();
  while( digitalRead(pin) == LOW) {
    if( micros() - start >= timeout ) {
      return timeout;
    }
  }
  return micros() - start;
}

"By the way - why did you swap your Master and Slave lines compared to your original post?" Well, i was confused there.

If i put your script on arduino is that the result:

Timing measurements in microseconds
Master line 0: 2000000
Master line 1: 2000000
Master line 2: 2000000
Master line 3: 2000000
Master line 4: 2000000
Master line 5: 2000000
Master line 6: 2000000
Master line 7: 2000000
Master line 8: 2000000
Master line 9: 2000000
Master line 10: 2000000
Master line 11: 2000000
Master line 12: 2000000
Master line 13: 2000000
Master line 14: 2000000
Master line 15: 2000000

There is either no result if i hit a field.

You could try doing that code with the slave lines. At this point, it is really up to you since you have the hardware.

ok lets try it on a another way.

int masterLines = 16; //Change here to the number of lines of your Master Layer
int slaveLines = 4; //Change here to the number of lines of your Slave Layer
int matrixMaster[] = {26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 53, 51}; //Put here the pins you connected the lines of your Master Layer
int matrixSlave[] = { 22, 24, 49, 47 }; //Put here the pins you connected the lines of your Slave Layer


void setup() {     
    Serial.begin(9600);     
    Serial.println("OpenDarts"); //This line is not necessary, is just here for debug purposes
    for(int i = 0; i < slaveLines; i++){         
        pinMode(matrixSlave[i], INPUT_PULLUP);     
    }
   for(int i = 0; i < masterLines; i++){         
       pinMode(matrixMaster[i], OUTPUT);         
       digitalWrite(matrixMaster[i], HIGH);     
   } 
}
void loop() {     
    for(int i = 0; i < masterLines; i++){         
        digitalWrite(matrixMaster[i], LOW);         
        for(int j = 0; j < slaveLines; j++){             
            if(digitalRead(matrixSlave[j]) == LOW){                 
                Serial.print(j);                 
                Serial.print(",");                 
                Serial.println(i);      
                delay(500);                 
                break;             
            }         
        }         
        digitalWrite(matrixMaster[i], HIGH);     
    } 
}

I connected the matrix ONLY on the arduino board. Now i recive all right datas.

Now i want to send the Signal from the Arduino to the dart machine.

For Example: I throw T5. Than i get as output "0,0". The first 0 is the pin 23, the secound pin 25 of the arduino board. How can i send this output to my machine ?

Do you think this is easier to archive this ?

int masterLines = 16; //Change here to the number of lines of your Master Layer
int slaveLines = 4; //Change here to the number of lines of your Slave Layer
int matrixMaster[] = {26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 53, 51}; //Put here the pins you connected the lines of your Master Layer
int matrixSlave[] = { 22, 24, 49, 47 }; //Put here the pins you connected the lines of your Slave Layer


void setup() {     
  Serial.begin(9600);
}
void loop() {     

 for(int j = 0; j < slaveLines; j++)
 {             
    if (digitalRead(matrixSlave[j]) == HIGH)
    {
      for (int i = 0; i < masterLines; i++)
      {
          if (digitalRead(matrixMaster[i]) == LOW)
         {       
                Serial.print(j);
                Serial.print(" - ");
                Serial.println(i);
                delay(500);
                break;
         }
      }
    }
 }
 


}

So now I'm receiving the right data. I only have the problem that only about 80% of the litters arrive. How can that be?

I found the problem. If i the impact of the throw is not hard enough, the Slave does not go high.

Can anyone explain me why?

Is there any workaround for this?