Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Teensy LC stops when Ableton playback is engaged

  1. #1
    Junior Member
    Join Date
    Nov 2019

    Teensy LC stops when Ableton playback is engaged

    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



    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.
    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:
    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:
    usbMIDI.sendControlChange ( 1, sensorValue, 1 );
    usbMIDI.sendControlChange ( 2, sensorValue2, 1 );
    delay(15); // delay in between reads for stability

    Click image for larger version. 

Name:	IMG_4083.jpg 
Views:	12 
Size:	110.1 KB 
ID:	18219

  2. #2
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Isle in the Salish Sea
    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.
    See Transmit Issues:
    // MIDI Controllers should discard incoming MIDI messages.
    while ( {
    // 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 by oddson; 11-18-2019 at 10:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts