how to have to a GPIO pin give the same outpout when other GPIO pin is hit ?

Hi community :slight_smile:

I’m working on the OpenDarts projects.
Things is, my old Dartboard has different output for Outer and Inner singles, and the code was developed with a Dartboard that would give the same output for Outer or Inner singles.

I’ve found that the singles pin are on the masterLines.

pin #34 is inner singles from 1 to 3 on the dartboard
pin #40 is outer singles from 1 to 3 on the dartboard

pin #44 is outer singles from 19 to 20 on the dartboard
pin #52 is outer singles from 19 to 20 on the dartboard

Now, it’s easy enough for me (an objective C noob!) to connect wire 34-40 and 44-52 together to get the same output for inner and other singles, but I’m very courious to know how I could adapt the code to tell Arduino to digitalWrite the same value when pin 34or40 (ans 44or52) is hit ?

I dunno if I was clear enough…

Thanks in advance to how will want to help :slight_smile:
Francois.

here’s the code :

int masterLines = 10; //Change here to the number of lines of your Master Layer
int slaveLines = 10; //Change here to the number of lines of your Slave Layer

int matrixMaster[] = {34, 36, 38, 40, 42, 44, 46, 48, 50, 52}; //Put here the pins you connected the lines of your Master Layer
int matrixSlave[] = {35, 37, 39, 41, 43, 45, 47, 49, 51, 53}; //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 am not sure what exactly you want to do, but it seems than an output pin should go HIGH when either pin 34 or pin 40 goes HIGH. Is that what you want ?

UKHeliBob:
I am not sure what exactly you want to do, but it seems than an output pin should go HIGH when either pin 34 or pin 40 goes HIGH. Is that what you want ?

yes, indeed... :slight_smile:

you said what I wanted to say in one sentence !! hahaha ! sorry !

if (digitalRead(34) == HIGH || digitalRead(40) == HIGH)
{
  digitalWrite(somePin, HIGH);
}

You can, of course, use the values from the arrays instead of the actual pin numbers, and you need to turn off the output pin at some point.

I suspect that there is more to your requirement than you have asked.

Thanks a lot UKHelibob :slight_smile:

Brain hurts from so much learning today !

Will try it out :slight_smile:

MErci !