Help needed with circuit

I’ve got the following input array. The black lines are metal bars and the red lines are uninsulated wires.

The user creates inputs by pressing between two metal bars, not at the bar/wire intersection causing the bar previous in the alphabet to also show continuity with the wire. ie: Wire 1 is pressed between bars C&D causing continuity at bars C&D. Normally this is fine as the letter previous in the alphabet is usually ignored.

The problem I’m experiencing is that if on wire 2 I press between bars D&E while pressing on wire 1 between C&D wire 1 and wire 2 both have continuity on C, D, & E because everything is conductive.

Because both wires have the same continuity values, there is no way in code to tell which wire is meant to be touched to which bar causing them both to be reported at the higher letter in the alphabet because the higher letter is reported.

This circuit works perfectly as expected as long as there are no two wires touching adjacent bars.

Is there a way I could make this circuit work without modifying it too much?

I appreciate any help that can be given!

Here’s a PDF of the circuit on a breadboard. To make it sync with my description above string = wire and fret = bar.
http://www.cribbstechnologies.com/pcguitar_bb.pdf

//define strings
int lowe = 2;
int a = 3;
int d = 4;
int g = 5;
int b = 6;
int highe = 7;

int strings[] = {lowe, a, d, g, b, highe};


//define frets
int fret1 = 8;
int fret2 = 9;
int fret3 = 10;
int fret4 = 11;
int fret5 = 12;
int fret6 = 13;

int frets[] = {fret6, fret5, fret4, fret3, fret2, fret1};

boolean found;

void setup() {
  pinMode(lowe, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(highe, OUTPUT);
  pinMode(fret1, INPUT);
  pinMode(fret2, INPUT);
  pinMode(fret3, INPUT);
  pinMode(fret4, INPUT);
  Serial.begin(38400);
}

void loop() {

  for (int string = 0; string < 6; string++) {
    digitalWrite(strings[string], HIGH);

    Serial.print(string);
    Serial.print(",");
    //loop through the frets backward, 
    //if a value is found, stop, highest string winsyeah
    found = false;   
      for (int fret = 0; fret < 6 ; fret++) {
       if (digitalRead(frets[fret]) == HIGH) {
         int fretNum = frets[fret] - 8;
         found = true;
        Serial.print(fretNum);
        break; 
        }
      }
      if (!found) {
        Serial.print("-1");
      }
      
      if (string < 5) {
       Serial.print(","); 
      } else {
        Serial.println();
    
      }
      digitalWrite(strings[string], LOW);

  }

}

Diodes might help.

Take a look here:

http://www.dribin.org/dave/keyboard/one_html/

That setup is a bit different that mine. In my situation I can't modify the bars or wires, only the connections to the arduino. In this case, I can't see how diodes would help the situation.

If all the bars are electrically common then there is no way to do this.

If you can separate the bars and feed them into separate arduino inputs then yes you can do it.

Is there only 6 strings and 5 bands?

Grumpy Mike, the bars are all on their own separate arduino inputs. How do you suggest I modify my circuit to make this work?

andpe, there's 6 strings and 24 bands, I'm just getting the circuit working smaller scale before I throw the multiplexers in there.

Bump, I could really use a hand guys.

No one? Bueller?

Put a diode in between the arduino outputs and the bars. Then put a pull down resistor on all the column inputs to the arduino. Then scan it so that only one row is high at any one time and look at the column inputs.

I fail to see how that would make the circuit behave any differently than it does currently. Can you explain why that would be different?

At the moment you have all the inputs going to a common ground, or at least that's what you circuit had despite all your software.

With the rows connected to separate outputs and the columns to separate inputs you isolate the contacts.

One row is high and the others low, the diode prevents any high output being shorted out by the other row outputs being low. As one output is high then key presses to the rows not high do not pull up any inputs as they have a pull down resistor on them. Any short between a row that is high and a column will be detected.

I still don't see how that would solve the problem. In the picture below, the circuit would be touched where the black circles are. In this case, string 1 and string 4 would both have continuity on bars A, B and C. The circuit is pressed BETWEEN bars, not ONTO bars. If I press the wires onto the bars, no problem, everything works great but that's not how the object is intended to be used.

Pressing between bars would, in effect, be like pressing on two adjacent horizontal bars in one column at the same time, would it not?

The diodes+read-one-column-at-a-time could "see" this, and give you what you need... I think... or am I missing something?

tkbyd: yes, it would be in effect pressing on two adjacent horizontal bars. How would the diodes help in this situation? Everything is conductive so when you touch between adjacent bars, whichever bar is common would conduct through to all other wires touching that bar. Let's walk through the pseudocode:

E high, scan all wires, no input, E low D high, scan all wires, no input, E low C high, scan all wires, 1 and 4 are high, C low B high, scan all wires, 1 and 4 are high, B low A high, scan all wires, 1 and 4 are high, A low

The circuit is pressed BETWEEN bars, not ONTO bars.

Does this mean that when 1 is pressed then it connects to A, B, C, D, & E all at the same time?

EDIT Or do you mean that in that diagram A is connected to B but also B is connected to C due to the second press?

Your edit is correct.

Let's walk through the pseudocode:

E high, scan all wires, no input, E low D high, scan all wires, no input, E low C high, scan all wires, 1 and 4 are high, C low B high, scan all wires, 1 and 4 are high, B low A high, scan all wires, 1 and 4 are high, A low

In reality, it would look like this:

E high, scan all wires, no input, E low D high, scan all wires, no input, E low C high, scan all wires, 4 is high, C low B high, scan all wires, 1 and 4 are high, B low A high, scan all wires, 1 is high, A low

Each wire will only be touching 2 bars, not 3 like you were speculating. So you will notice that you can tell by the pattern which wires are being pressed. Looking at the pattern read in, the 1 wire is touching A and B and the 4 wire is touching B and C. You just use a pattern recognition routine to tell the rest of your program what to do based on the results.

Hope this is understandable and helps you out.

Dan

Dan: What keeps the press on string 4 from backfeeding into string 1 via bar B causing what I'm seeing now in my current code/circuit?

Ok I am not sure you can do all of it in that case but consider this situation.

Have pull downs on all arduino connections. Set 1 to 6 as inputs Then make A an output and high with B, C, D, E inputs. So you will see 1 as high and B and C as high. As you know the A is high you would expect only B to be high. As C is also high you know that there are two or more are pressed down at once. You can't tell what they are but you know it is more than one.

So when you make one of the rows an output at high make all the others inputs. If only one row input is high then you have a single press.

I think that is all you can do.

Are you planing on actually using like steel guitar strings and metal fret bars? If so, nothing will keep it from showing on all 3 bars. You need to isolate your bar segments for each string with a diode to keep it from feeding back into other strings.

So, you would actually end up with 6 segments of bar for each of the notes with a diode between each bar segment on each note.

| | | | | | | ---- | ---- | ---- | ---- | ---- | --+-| d|-+-| d |-+-| d |-+-| d |-+-| d|-+-- Bar A | ---- | ---- | ---- | ---- | ---- | | | | | | | | ---- | ---- | ---- | ---- | ---- | --+-|d |-+-| d |-+-| d |-+-| d |-+-| d|-+-- Bar B | ---- | ---- | ---- | ---- | ---- | | | | | | | 1 2 3 4 5 6

The diagram shows the strings crossing the bar segments with the boxes with the d in them being the isolation diodes. This would allow the current to flow through each bar for each string but will not let the current flow backwards through each bar into a previous string.

I hope this is understandable. I can't draw too good with text. ::) Dan