Interrupt on teensy 4.0 + Adafruits Neotrellis

It works but from time to time stops receiving from serial until I press again....

Perhaps your serial code is somehow getting out of sync with the data?

From only a quick glance at the code, it seems to just grab 6 bytes and use them without any checking whether they really are the intended bytes. If it ever gets out of sync, you'd have a 1 in 6 chance of grabbing the intended bytes. Otherwise, you might grab the pixel colors and mistakenly use them as the X & Y coordinates.

Normally this sort of communication uses a unique or unlikely byte or sequence of bytes as a header. If the received data doesn't have a proper header, usually some sort of re-sync is done, like discarding bytes until the header is seen.
 
Nope.

Try this with same result

Code:
void loop() {


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

     }  
  
  if (Serial.available() > 0) {

                    
      v1 = Serial.read();
     
     
      if (v1== 0 ) {
     
      v2 = 31;
    } 
      
      else {

      v2 =  v1 - 1 ;    
      }  
      
      trellis.setPixelColor(v2 , rgbColor(0,0,0) ); 
      trellis.setPixelColor(v1 , rgbColor(0,100,0) ); 
      
     trellis.show();
           
   }
       
 }


I could do things differently but I dont know if is not the same ..


I could program the light sequence on the teensy.


I would only use serial once each time to indicate color numbers of lights to loop.

But then I would have the problem of timing. I whould still need serial to send the clock of the PC soft..
 
Back
Top