Greetings @teensy_ino
It seems from post #1 you have one string working and have a good idea at hand for that. Without code and perhaps drawings to visualize what that consists of a lot is on the reader to see what is there.
It seems the un-split frets is the problem as conductivity from multi touch is cross feeding the test and measure process? In some ways to read this might be like a
button keypad. With each fret and string wired the contact point could be known.
Also - perhaps no affect here but TeensyDuino current is 1.51 with 1.52 in beta so any fixes or issues would be against the current release.
Hi defragster,
many thanks for your response !
Teensyduino is installed in my version 1.52.
Briefly again to explain:
I used a voltage divider to query the frets with a slightly modified ohmmeter sketch analog.
The voltage divider is on one side at + 5V, all frets are connected together in series with the same
resistance values (3,3k, 1%).
The other end of the voltage divider is (currently) firmly on GND to close the circuit.
The measurement of the total resistance itself runs in a loop.
The string is also firmly on GND.
If the string touches a fret, GND bridges the relevant resistance of the fret and outputs the change
as a MidiNote.
Here is the circuit diagram (I use 3,3k Resistors at eachpoint):
For the sake of clarity, I only used 3 resistance values / midi notes in the sketch. I had successfully
tested this before on the breadboard with 24 resistors.
It is clear to me that the function with several strings should theoretically look like a keyboard matrix
consisting of columns and rows.
To do this you would have to have split frets that are not available ...
Ideally, every single split fret and additionally every single string would be wired (that would be the
matrix). But then also means 6 x 24 individual cables that somehow want to be housed in the guitar
neck ...- Apart from the amount of inputs that would then be needed ...
However, since it is not possible to get split frets, I chose the voltage divider approach (only 1 wire
plus resistors) and can then live with slightly restricted functions in polyphony.
Sketch:
Code:
// getestet mit Teensy 3.2, IDE 1.8.12 / Teensyduino 1.52, WIN 10
// USB-Type " MIDI"
// Widerstände messen
// _____
// -|_R1__|- VCC
//AnalogPin -' _____
// '-|_R2__|- GND
// R2 = zu messender Messwert (Reihenschaltung von mehreren 3,3k Widerständen)
const int channel = 1;
float Quellspannung = 3.30;
int AnalogPin = 0;
int R1 = 3280.0; //Wert des bekannten Messwerts(3,3k, nachgemessen = 3280)
long Messwert;
float SpannungR2; //Spannung über dem zu messenden Widerstand
float Widerstand = 0;
float WiderstandAlt = 0;
int midineu = 0;
int midiold = 0;
void setup()
{
//Pullups:
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
Serial.begin(115200);
Serial.println("Widerstand ausmessen");
Serial.println();
}
//==================================================================
void loop (){
//5 Messungen machen und Mittelwert bilden
Messwert = 0;
for (int i = 0; i < 5; i++) {
Messwert += analogRead(AnalogPin);
}
Messwert = trunc(Messwert / 5);
//Spannung berechnen
SpannungR2 = (Quellspannung / 1023.0) * Messwert;
Serial.print("Spannung ueber R2 betraegt ");
Serial.print(SpannungR2, 2);
Serial.println(" Volt!");
//Berechnung: (R2 = R1 * (U2/U1))
Widerstand = R1 * (SpannungR2 / (Quellspannung - SpannungR2));
Serial.print("Der Widerstand hat ");
Serial.print(Widerstand, 2);
Serial.println(" Ohm.");
Serial.println();
switch (int(Widerstand))
{
case 2970 ... 3630 : midineu = 60; break; // Widerstand 1. Fret
case 5940 ... 7260 : midineu = 61; break; // Widerstand 2. Fret
case 8910 ... 10890 : midineu = 62; break; // Widerstand 3. Fret, getestet mit 24 Frets
default: midineu = 0; break; //wenn Alles nicht passt, dann Taste losgelassen
}
if (midineu != midiold) {
//es hat sich was geändert
if (midineu > 0)
usbMIDI.sendNoteOn(midineu, 127, 1); // nur diese Zeile verändert
if (midiold >= midineu)
usbMIDI.sendNoteOff(midiold, 0, 1);
midiold = midineu;
// MIDI Controllers should discard incoming MIDI messages.
while (usbMIDI.read()) {
// read & ignore incoming messages
}
//delay(200); // Verzögerung zum Lesen der Anzeige, fliegt sonst raus!
}
}
//===========================================================
To enable a differentiation by strings, I need an additional trigger. The only question is how?
But since the string is already electrically at GND in order to be able to bridge the resistance of the
fret, I cannot use the same string again as a trigger for string detection.
Anyway, at the moment I don't know how ...
Has anyone got an idea ?
Greetings from Germany !