Neotrellis-Multitrellis interrupt question

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Moris526
 
Posts: 91
Joined: Fri Jan 17, 2020 10:09 am

Neotrellis-Multitrellis interrupt question

Post by Moris526 »

Hi.

I have 32 Neotrellis boards soldered together in a 4x8 grid https://learn.adafruit.com/adafruit-neotrellis

If I load only 1 board the interrupt function works fine but if I load the 32 boards (multitrellis) the behaviour is erratic.

For example I have this in the Loop function

Code: Select all

void loop() {
  if (!digitalRead(INT_PIN)) {
    trellis.read();
    Serial.println("Hello");
  }
Sometimes when I press a button prints Hello and when I let go prints again. But Some other times I press the button and it keeps printing Hello. If I press again then maybe it stops and works fine for a few times and then again it keeps printing.

Someone noticed this difference beetwen Neotrellis (only loading 1 board) and Multitrellis .
I dug into the libraries a bit and it turns out that you have the option of polling or not for a single trellis board, but once you switch over to the multitrellis class, it is simply .read()
This is the 1 board Loop

Code: Select all

void loop() {
  if (!digitalRead(INT_PIN)) {
    trellis.read(false);
    Serial.println("Hello");
  }
Could that be the problem???

Another thing I dont get is if I load this

Code: Select all

void loop() {
  if (!digitalRead(INT_PIN)) {
       Serial.println("Hello");
  }
When I press a button It just keeps printing in both one board or many

Here is the full code for the multitrellis

Code: Select all

/* 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);
 
  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)){
    
     trellis.read();
    Serial.println("Hello");
  }
  delay(2);
}

User avatar
Moris526
 
Posts: 91
Joined: Fri Jan 17, 2020 10:09 am

Re: Neotrellis-Multitrellis interrupt question

Post by Moris526 »

If I load only 1 board ( thou they are soldered together) it works fine. I messured the interrupt pin voltage and get

Not button pressed 3.26 v
Button pressed between 3.10 and 3.20 v and goes back to 3.26 v

If I load 32 boards and messure the interrupt pin voltage I get

Not button pressed 3.26 v
Button pressed between 2.40 and 3.13 (mostly below 2.80) and back to 3.26v

But from time to time in this case the voltage goes down to 0.80 and stays there until I press again a few time and goes back up to 3.26v

I try PULL_UP in the code with no luck...

Any Idea?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”