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);
}
}