mcp23017 problem

Hellow,

I've been working on a 4X4X4 led-cube, ive made the cube and decided to use 2 mcp23017 chips.
I'm using the adafruit library for these chips. I've made multiple effects for my ledcube but i keep struggling with the same problem. My ledcube keeps having a "flashing" effect. I think my mcp23017 is reacting to slow... I'm using the function delayMicroseconds and then reset the entire cube before i set other outputs to high... can somebody help me out ? I'm pretty new to arduino so my program is probably not very good... sorry for that i'm here to learn :), feel free to write an example if you like and ill e-mail the result to you if you like so...

im using an arduino UNO
and 2 mcp23017's

this is part of my code:

#include <Wire.h>
#include "Adafruit_MCP23017.h"

Adafruit_MCP23017 expander0;
Adafruit_MCP23017 expander1;
  
void setup() {  
  
  Serial.begin(9600);
  expander0.begin(0);      // first expander at address 0
  expander1.begin(1);      // second expander at address 1
  

for (int thisPin1 = 0; thisPin1 < 17; thisPin1++)  {    
  expander0.pinMode(thisPin1, OUTPUT); }
for (int thisPin2 = 0; thisPin2 < 17; thisPin2++){
  expander1.pinMode(thisPin2, OUTPUT);
}}



void loop(){

for (int levelcross4 = 0; levelcross4 < 3; levelcross4 ++){
  
  for (int crossloop1 = 0; crossloop1 <5; crossloop1++){
   
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
  
    delayMicroseconds(1);
     expander1.digitalWrite(4,HIGH);//level(4)//
     expander1.digitalWrite(6,HIGH); //row 2 led 2 // 
     
    delayMicroseconds(1);  
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
      
    delayMicroseconds(1);
      expander1.digitalWrite(4,HIGH);//level(4)//
      expander1.digitalWrite(15,HIGH); //row 1 led 2 //
      expander1.digitalWrite(14,HIGH); //row 3 led 2 //

...

this code is working but i've got that terrible flashing effect...

can somebody help me out ?

Maybe.

this is part of my code:

If you'd like part of an answer, you need to

Hi, if it helps i can post the entire code but its verry long ... and its always repeating what ive posted in the example above... so the problem has to jebe in the way of coding :frowning:

You can attach code to the forum post.
How to use this forum
http://snippets-r-us.com/

Here is the entire code i'm using :wink:

#include <Wire.h>
#include "Adafruit_MCP23017.h"

Adafruit_MCP23017 expander0;
Adafruit_MCP23017 expander1;
  
void setup() {  
  
  Serial.begin(9600);
  expander0.begin(0);      // first expander at address 0
  expander1.begin(1);      // second expander at address 1
  

for (int thisPin1 = 0; thisPin1 < 17; thisPin1++)  {    
  expander0.pinMode(thisPin1, OUTPUT); }
for (int thisPin2 = 0; thisPin2 < 17; thisPin2++){
  expander1.pinMode(thisPin2, OUTPUT);
}}



void loop(){

for (int levelcross4 = 0; levelcross4 < 3; levelcross4 ++){
  
  for (int crossloop1 = 0; crossloop1 <5; crossloop1++){
   
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
  
    delayMicroseconds(1);
     expander1.digitalWrite(4,HIGH);//level(4)//
     expander1.digitalWrite(6,HIGH); //rij 2 led 2 // 
     
    delayMicroseconds(1);  
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
      
    delayMicroseconds(1);
      expander1.digitalWrite(4,HIGH);//level(4)//
      expander1.digitalWrite(15,HIGH); //rij 1 led 2 //
      expander1.digitalWrite(14,HIGH); //rij 3 led 2 //
      
    delayMicroseconds(1);  
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
    
    delayMicroseconds(1);    
      expander1.digitalWrite(4,HIGH);//level(4)//
      expander1.digitalWrite(5,HIGH); //rij 0 led 2 //
      expander1.digitalWrite(13,HIGH); // rij 4 led 2 //
      
    delayMicroseconds(1);
  }
  
  for (int crossloop2 = 0; crossloop2 < 5; crossloop2++){
    
    for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
      
      delayMicroseconds(1);
      
      expander1.digitalWrite(4,HIGH);//level(4)//
      expander1.digitalWrite(10,HIGH);// rij 2 led 0 //
      expander0.digitalWrite(10,HIGH);// rij 2 led 4 //
      
      delayMicroseconds(1);
      
    for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}    
      
      delayMicroseconds(1);
      
      expander1.digitalWrite(4,HIGH);//level(4)//
      expander0.digitalWrite(13,HIGH); // rij 2 led 1 //
      expander0.digitalWrite(2,HIGH); // rij 2 led 3 //
      
     delayMicroseconds(1);
     
   for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}    
    
   delayMicroseconds(1);

     expander1.digitalWrite(4,HIGH);//level(4)//
     expander1.digitalWrite(6,HIGH); //rij 2 led 2 // 
     
  delayMicroseconds(1);
  
   for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}      
      
  }

    for (int crossloop3 =0; crossloop3 < 5; crossloop3++){  
    
  delayMicroseconds(1);
  
    expander1.digitalWrite(4,HIGH);//level(4)//
    expander1.digitalWrite(8,HIGH);// rij0 led 0 //
    expander0.digitalWrite(12,HIGH);// rij 4 led 4 //
    
  delayMicroseconds(1);
  
       for (int reset1 = 0; reset1 <17; reset1++){
        expander0.digitalWrite(reset1,LOW);}
        for (int reset2 = 0; reset2 <17; reset2++){
        expander1.digitalWrite(reset2,LOW);}    
      
  delayMicroseconds(1);
  
    expander1.digitalWrite(4,HIGH);//level(4)//
    expander0.digitalWrite(15,HIGH);// rij 1 led 1 //
    expander0.digitalWrite(3,HIGH); // rij 3 led 3 //
    
 delayMicroseconds(1);
 
     for (int reset1 = 0; reset1 <17; reset1++){
        expander0.digitalWrite(reset1,LOW);}
        for (int reset2 = 0; reset2 <17; reset2++){
        expander1.digitalWrite(reset2,LOW);}    
        
 delayMicroseconds(1);
       
    expander1.digitalWrite(4,HIGH);//level(4)//
    expander1.digitalWrite(6,HIGH); //rij 2 led 2 // 
     
       }                
}
 for (int crossloop1 = 0; crossloop1 <5; crossloop1++){
   
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
  
    delayMicroseconds(1);
     expander1.digitalWrite(4,HIGH);//level(4)//
     expander1.digitalWrite(6,HIGH); //rij 2 led 2 // 
     
    delayMicroseconds(1);  
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
      
    delayMicroseconds(1);
      expander1.digitalWrite(4,HIGH);//level(4)//
      expander1.digitalWrite(15,HIGH); //rij 1 led 2 //
      expander1.digitalWrite(14,HIGH); //rij 3 led 2 //
      
    delayMicroseconds(1);  
      for (int reset1 = 0; reset1 <17; reset1++){
      expander0.digitalWrite(reset1,LOW);}
      for (int reset2 = 0; reset2 <17; reset2++){
      expander1.digitalWrite(reset2,LOW);}  
    
    delayMicroseconds(1);    
      expander1.digitalWrite(4,HIGH);//level(4)//
      expander1.digitalWrite(5,HIGH); //rij 0 led 2 //
      expander1.digitalWrite(13,HIGH); // rij 4 led 2 //
      
    delayMicroseconds(1);
  }

 }