teensy_ino
Active member
Hello everybody,
I'm new here, have been working on Arduino for some time and recently also with Teensy 3.2 / 3.5.
With the Teensy I was able to implement one or the other midi controller.
Would be happy if I could get support here!
I am currently using Teensy 3.2 / 3.5
IDE 1.86 Settings:
Board Teensy 3.1/3.2
USB Type: Midi
CPU Speed: 72 MHz
Optimize: Faster
Teensy Loader 1.45
WIN 10
In the current project I would like to use the TouchRead function of Teensy 3.2 (with USB Midi) to determine the finger position on a guitar.
The Guitarstring should act like a large slider or ribbon controller so that midi notes can be assigned to the recorded values.
I used the example sketch of the CapacitiveSensor Library (with 10 M Resistor) and connected a single Guitarstring as a sensor surface (2 wire version).
Unfortunately, the displayed value in the serial monitor does not change.
In "Suspicion" I have the "millis" in line 20.
Which value ( in Hex or Decimal ? ) must be used there?
In another test (one Guitarstring as sensor surface, with / without 10M Resistor) I only used the nativ TouchRead function (1 wire method without Libary).
Although values are displayed here, they fluctuate very strongly and are unfortunately also independent of the finger position ...
Can a guitar string be used as a sensor surface in this way, like a large slider, with the TouchRead function?
Many thanks in advance for your responses !
Greetings from Germany
I'm new here, have been working on Arduino for some time and recently also with Teensy 3.2 / 3.5.
With the Teensy I was able to implement one or the other midi controller.
Would be happy if I could get support here!
I am currently using Teensy 3.2 / 3.5
IDE 1.86 Settings:
Board Teensy 3.1/3.2
USB Type: Midi
CPU Speed: 72 MHz
Optimize: Faster
Teensy Loader 1.45
WIN 10
In the current project I would like to use the TouchRead function of Teensy 3.2 (with USB Midi) to determine the finger position on a guitar.
The Guitarstring should act like a large slider or ribbon controller so that midi notes can be assigned to the recorded values.
I used the example sketch of the CapacitiveSensor Library (with 10 M Resistor) and connected a single Guitarstring as a sensor surface (2 wire version).
Unfortunately, the displayed value in the serial monitor does not change.
In "Suspicion" I have the "millis" in line 20.
Which value ( in Hex or Decimal ? ) must be used there?
Code:
#include <CapacitiveSensor.h>
/*
CapitiveSense Library Demo Sketch
Paul Badger 2008
Uses a high value resistor e.g. 10M between send pin and receive pin
Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
Receive pin is the sensor pin - try different amounts of foil/metal on this pin
*/
CapacitiveSensor cs_4_2 = CapacitiveSensor(4, 2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_4_6 = CapacitiveSensor(4, 6); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
CapacitiveSensor cs_4_8 = CapacitiveSensor(4, 8); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
void setup()
{
cs_4_2.set_CS_AutocaL_Millis[B][COLOR="#FF0000"](0xFFFFFFFF)[/COLOR][/B]; // turn off autocalibrate on channel 1 - just as an example
Serial.begin(115200);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(3);
long total2 = cs_4_6.capacitiveSensor(3);
long total3 = cs_4_8.capacitiveSensor(3);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing
Serial.print(total1); // print sensor output 1
Serial.print("\t");
Serial.print(total2); // print sensor output 2
Serial.print("\t");
Serial.println(total3); // print sensor output 3
delay(10); // arbitrary delay to limit data to serial port
}
In another test (one Guitarstring as sensor surface, with / without 10M Resistor) I only used the nativ TouchRead function (1 wire method without Libary).
Although values are displayed here, they fluctuate very strongly and are unfortunately also independent of the finger position ...
Code:
int touchRead_pin_1 = 0; //Digital PIN 1
int touchRead_pin_2 = 1; //Digital PIN 2
int thresh = 5200; // Original = 2200
int play_flag_1 = 0;
int play_flag_2 = 0;
int current_1;
int current_2;
int delay_time = 100; // Original = 30
uint8_t touchPin [2] = {1,2}; // Liste der TouchPins
int ntouch = 2; // n wird für Loop-Kriterien verwendet, erhöhen um mehr Touch-Pins zu verwenden
int touchValue = 0; // gespeicherter Wert für Touch-Messwerte
void setup() {
Serial.begin (9600); // Seriell Monitor aktivieren
}
void loop() {
for (uint8_t i = 0; i < ntouch; i ++) {
touchValue = touchRead (touchPin [i]);
Serial.print ("touchPin:");
Serial.print (touchPin [i]);
Serial.print ("");
Serial.print ("Value:");
Serial.println (touchValue);
current_1 = touchRead(touchRead_pin_1);
if (current_1 > thresh && play_flag_1 == 0) {
play_flag_1 = 1;
usbMIDI.sendNoteOn(60, 127, 1);
delay(delay_time);
}
if (current_1 < thresh && play_flag_1 == 1) {
play_flag_1 = 0;
usbMIDI.sendNoteOff(60, 0, 1);
delay(delay_time);
}
current_2 = touchRead(touchRead_pin_2);
if (current_2 > thresh && play_flag_2 == 0) {
play_flag_2 = 1;
usbMIDI.sendNoteOn(62, 127, 1);
delay(delay_time);
}
if (current_2 < thresh && play_flag_2 == 1) {
play_flag_2 = 0;
usbMIDI.sendNoteOff(62, 0, 1);
delay(delay_time);
}
}
}
Can a guitar string be used as a sensor surface in this way, like a large slider, with the TouchRead function?
- If yes, how ?
- If not, what other options are there for implementation (e.g. Prop Shield, QT ICs)?
Many thanks in advance for your responses !
Greetings from Germany