Teensy LC stops when Ableton playback is engaged

Status
Not open for further replies.

sillymann

New member
Hello PJRC peeps,
I am a newbie Teensyduino user that has run into an issue. I am attempting to make a glove with flex sensors on the fingers that can be assigned to any parameter in Ableton. Serial print in Arduino works fine. When I have the sensors assigned to a parameter in Ableton and playback is OFF it works. When I press the play back button it works for about a second then stops. i have tried switching to a shorter chord, making sure my computer is charging, and cross checked in max (it works in max)

Using Teensy LC and Adafruit flex sensors on a Mac


CODE:

/*
AnalogReadSerial

Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
const int numReadings = 1000;

int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0;

int inputPin = 15;

const int numReadings2 = 1000;

int readings2[numReadings2]; // the readings from the analog input
int readIndex2 = 0; // the index of the current reading
int total2 = 0; // the running total
int average2 = 0;

int inputPin2 = 17;


// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(15);
sensorValue = map ( sensorValue, 840, 940, 0, 127 );
sensorValue = constrain (sensorValue, 0, 127);

int sensorValue2 = analogRead(17);
sensorValue2 = map ( sensorValue2, 840, 940, 0, 127 );
sensorValue2 = constrain (sensorValue2, 0, 127);

// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = analogRead(inputPin);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;



// if we're at the end of the array...
if (readIndex >= numReadings) {
// ...wrap around to the beginning:
readIndex = 0;
}

// calculate the average:
average = total / numReadings;
// print out the value you read:
Serial.println(sensorValue);
Serial.println(sensorValue2);
usbMIDI.sendControlChange ( 1, sensorValue, 1 );
usbMIDI.sendControlChange ( 2, sensorValue2, 1 );
delay(15); // delay in between reads for stability
}









IMG_4083.jpg
 
Welcome
You're not the first to miss this little nugget.

You need to read incoming midi even if you are not using them. It stops an event queue on the computer from getting bogged down with events that are never requested.

https://www.pjrc.com/teensy/td_midi.html
See Transmit Issues:
// MIDI Controllers should discard incoming MIDI messages.
while (usbMIDI.read()) {
// read & ignore incoming messages
}



If you need to post code in future you'll get more reviewer attention if you put it in CODE tags which are inserted by the [#] button on the advanced option in edit or you can type [CODE] and [/CODE]
 
Last edited:
Status
Not open for further replies.
Back
Top