Interrupt on teensy 4.0 + Adafruits Neotrellis

Hi all.

Im using Teensy 4.0 to control Adafruits Neotrellis 16 LEd/button board programing it with Arduino Ide

All works fine with the Adafruit example but the interrupt function ( it works fine with an arduino uno board)

 void loop() {
   if(!digitalRead(INT_PIN)){
    
    Serial.println("Hello");
   }
   delay(2);
 }

When I press the button I get "Hello" printed continuosly but when I let it go it keeps printing.

any idea?

What does this have to do with interrupts? Post the complete code. Try INPUT_PULLUP.

What does this have to do with interrupts?

It is an interrupt signal thats coming from the Neotrellis board

/* This example shows basic usage of the NeoTrellis
  with the interrupt pin.
  The buttons will light up various colors when pressed.
*/

#include "Adafruit_NeoTrellis.h"

Adafruit_NeoTrellis trellis;

#define INT_PIN 8

// Input a value 0 to 255 to get a color value.
// The colors are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return trellis.pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return trellis.pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return trellis.pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

//define a callback for key presses
TrellisCallback blink(keyEvent evt){
  
  if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING)
    trellis.pixels.setPixelColor(evt.bit.NUM, Wheel(map(evt.bit.NUM, 0, trellis.pixels.numPixels(), 0, 255))); //on rising
  else if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_FALLING)
    trellis.pixels.setPixelColor(evt.bit.NUM, 0); //off falling
    
  trellis.pixels.show();
  return 0;
}

void setup() {
  Serial.begin(9600);
  //while(!Serial);

  pinMode(INT_PIN, INPUT_PULLUP);
  
  if(!trellis.begin()){
    Serial.println("could not start trellis");
    while(1);
  }
  else{
    Serial.println("trellis started");
  }

  //activate all keys and set callbacks
  for(int i=0; i<NEO_TRELLIS_NUM_KEYS; i++){
    trellis.activateKey(i, SEESAW_KEYPAD_EDGE_RISING);
    trellis.activateKey(i, SEESAW_KEYPAD_EDGE_FALLING);
    trellis.registerCallback(i, blink);
  }

  //do a little animation to show we're on
  for(uint16_t i=0; i<trellis.pixels.numPixels(); i++) {
    trellis.pixels.setPixelColor(i, Wheel(map(i, 0, trellis.pixels.numPixels(), 0, 255)));
    trellis.pixels.show();
    delay(50);
  }
  for(uint16_t i=0; i<trellis.pixels.numPixels(); i++) {
    trellis.pixels.setPixelColor(i, 0x000000);
    trellis.pixels.show();
    delay(50);
  }
}

void loop() {
  if(!digitalRead(INT_PIN)){
   
    Serial.println("trellis started");
  }
  delay(2);
}

With Pull up same result

Sure looks like Pin 8 is being held low. Why not use state change and detect the falling edge instead?

Can you give any link to read about that?

Arduino IDE:

Thank you.

I get the same result.

I detects the first change and nothing more

Could it be something on the teensy board?

Its says all digital pins a suited for interrups

Post a GitHub link for "Adafruit_NeoTrellis"

All I see is Adafruit_NeoTrellisM4: https://github.com/adafruit/Adafruit_NeoTrellisM4

This has nothing to do with interrupts on the Teensy. Your code uses no interrupts.

Put a voltmeter on Pin 8 and measure the voltage before, during, and after the button press.

Ok.

You example is missing a key component

void loop() {
  if(!digitalRead(INT_PIN)){
    trellis.read(false);
  }

void read()
read all events currently stored in the seesaw fifo and call any callbacks.

Thanks for the answer.

I try

void loop() {
  if(!digitalRead(INT_PIN)){
    trellis.read(false);
  }

and I get

Sketch: In function 'void loop()':
Sketch:107: error: no matching function for call to 'Adafruit_MultiTrellis::read(bool)'
     trellis.read(false); //This line is in the library example
                       ^
In file included from C:\Users\Moris\Desktop\Sketch\Sketch.ino:1:0:
C:\Users\Moris\Documents\Arduino\libraries\Adafruit_seesaw_Library/Adafruit_NeoTrellis.h:85:8: note: candidate: void Adafruit_MultiTrellis::read()
   void read();
        ^
C:\Users\Moris\Documents\Arduino\libraries\Adafruit_seesaw_Library/Adafruit_NeoTrellis.h:85:8: note:   candidate expects 0 arguments, 1 provided
Sketch: In function 'void (* blink(keyEvent))(keyEvent)':
Sketch:45: warning: control reaches end of non-void function 
 }
 ^
no matching function for call to 'Adafruit_MultiTrellis::read(bool)'

Sorry for my lack of knowledge. Im not a programmer, im trying to build a controller for a synth

What were the results of the test I suggested in Post #13?

Didnt get hold of a voltmeter yet

Where did you get your Adafruit NeoTrellis library? It may be different that what I showed?

Asked the same in Post #11.