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.