How to run two max7219 chips


my code
code: [select]
#include <ledcontrol.h>    //we cant without importing suitable library!

// lets start pinouts max72xx led driver
// *****************************************************
int v;
int m;

int seccountdown;
int seccountdown1;

int din = 12;              // pin 1  on max72xx
int clk = 11;              // pin 13 on max72xx
int loadcs = 10;// pin 12 on max72xx

int din1 = 8;              // pin 1  on max72xx
int clk1 = 13;              // pin 13 on max72xx
int loadcs1 = 9;

int flashdelay = 110;      // delay in ms (100=1/10th second)
int ledbrightness = 15;    // range 0-15.  0=lowest, 15 = full power

// define ledcontrol instance - if want more can setup lc2, lc3 etc
// ************************************************************************

ledcontrol lc=ledcontrol(din,clk,loadcs,2);
ledcontrol lc1=ledcontrol(din,clk,loadcs,2);// din, clk, load/cs, 1 = 1 chip max chip attached.

void setup()                    
{
 pinmode(din, output);        // once only, lets make pins outputs
 pinmode(clk, output);
 pinmode(loadcs, output);
 pinmode(din1, output);        // once only, lets make pins outputs
 pinmode(clk1, output);
 pinmode(loadcs1, output);
 pinmode(leddo, output);
 pinmode(ledxanh, output);
 pinmode(ledvang, output);
 // take pins out of power save mode.  no updates otherwise.
 for(int index=0;index<lc.getdevicecount();index++) {
   lc.shutdown(index,false);
 }
 for(int index1=0;index1<lc1.getdevicecount();index1++) {
   lc1.shutdown(index1,false);
 }
 lc.setintensity(0,ledbrightness  ); //set brightness
 lc1.setintensity(0,ledbrightness  );
}

void loop()                     // here comes stuff, main loop!
{
 int row = 0;                  //set starting position
 int chipid = 0;               //this not strictly reqd, if using more 1 display needed
  int tenths;
       int secones;
  int tenths1;
       int secones1;
 // first lets display hours
 // ****************************
(int seccountdown=20; seccountdown>=0; seccountdown--){
       v=seccountdown;
   
   
       tenths=v%10;                                         // again divide 10 , calculate remainder
       secones=v/10%10;                                      
       lc.setdigit(chipid, row, (byte) tenths, false);      
       lc.setdigit(chipid, row+1, (byte) secones, true);    // true in arguments activates dot...
      delay (flashdelay);
}
       
       for (int seccountdown1=15; seccountdown1>=0; seccountdown1--){
       m=seccountdown1;
     
       
       tenths1=m%10;                                         // again divide 10 , calculate remainder
       secones1=m/10%10;                                      
       //sectens=v/100%10;
       //thousands=v/1000%10;
       lc.setdigit(1, row, (byte) tenths1, false);      
       lc.setdigit(1, row+1, (byte) secones1, true);    // true in arguments activates dot...
     
      delay (flashdelay);
       }
     }

the code run, want use 2 max7219 chips display 7 segment led 2 value different
please me!!!!!!

you create 2 instances of ledcontrol (with dumb names - lc , lc1 (why not lc1 , lcd2?)). use 1 of them. why?


Arduino Forum > Using Arduino > Programming Questions > How to run two max7219 chips


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support