My code
#include <LedControl.h> //We cant do anything without importing a suitable library!
// Lets start with the pinouts to the Max72xx led driver
// *****************************************************
int v;
int m;
int seccountdown;
int seccountdown1;
int DIN = 12; // Pin 1 on the Max72xx
int CLK = 11; // Pin 13 on the Max72xx
int LOADCS = 10;// Pin 12 on the Max72xx
int DIN1 = 8; // Pin 1 on the Max72xx
int CLK1 = 13; // Pin 13 on the Max72xx
int LOADCS1 = 9;
int flashDelay = 110; // delay in MS (100=1/10th second)
int ledBrightness = 15; // range is 0-15. 0=lowest, 15 = full power
// define the LedControl instance - if I want more I can setup lc2, lc3 etc
// ************************************************************************
LedControl lc=LedControl(DIN,CLK,LOADCS,2);
LedControl lc1=LedControl(DIN,CLK,LOADCS,2);// DIN, CLK, Load/CS, 1 = only one chip MAX chip attached.
void setup()
{
pinMode(DIN, OUTPUT); // once only, lets make the pins outputs
pinMode(CLK, OUTPUT);
pinMode(LOADCS, OUTPUT);
pinMode(DIN1, OUTPUT); // once only, lets make the 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 the brightness
lc1.setIntensity(0,ledBrightness );
}
void loop() // here comes the good stuff, the main loop!
{
int row = 0; //Set the starting position
int chipId = 0; //This is not strictly reqd, but if using more than one display this will be needed
int tenths;
int secones;
int tenths1;
int secones1;
// First lets display the hours
// ****************************
for (int seccountdown=20; seccountdown>=0; seccountdown--){
v=seccountdown;
tenths=v%10; // Again divide by 10 and calculate the remainder
secones=v/10%10;
lc.setDigit(chipId, row, (byte) tenths, false);
lc.setDigit(chipId, row+1, (byte) secones, true); // True in the arguments activates the dot...
delay (flashDelay);
}
for (int seccountdown1=15; seccountdown1>=0; seccountdown1--){
m=seccountdown1;
tenths1=m%10; // Again divide by 10 and calculate the 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 the arguments activates the dot...
delay (flashDelay);
}
}
The code is run, I want to use two max7219 chips so display 7 segment led with two value different
Please help me!!!!!!