Now, 2 has appeared; but, the codes are in the loop() function.
When the MAX7219 is containing all the scanning circuitry, why should we put the codes in the loop() function. In the case of 8279 controller, we just write the data, whenever needed, into the data register of the controller; the controller just keeps driving the multiplexed display unit by virtue of its own scanning circuitry. I am using my own-made display array.
//int x;
void setup()
{
pinMode(8, OUTPUT); //LOAD Pin
pinMode(11, OUTPUT); //DIN Pin
pinMode(13, OUTPUT); //CLK Pin
PORTB = 0x00; //all pins low
}
void loop()
{
int x = 0x0C01; //normal Mode xxxx 1100 00000001
clkIn(x);
x = 0x0900; //no-decode mode xxxx 1001 00000000
clkIn(x);
x= 0x0AFF; //max intensity xxxx 1010 11111111
clkIn(x);
x= 0x0B07; //scan limit //8-digit : xxxx 1011 00001111
clkIn(x);
x = 0x016D; //xxxx 0001 01011011 ; digit 2 at DP0 position
clkIn(x);
}
void clkIn(int x)
{
for (int i = 15; i>=0; i--)
{
digitalWrite(11, bitRead(x, i)); //D15 is shifted first
//------
digitalWrite(13, HIGH);//generating clock signal
// delayMicroseconds(1);
digitalWrite(13, LOW);
}
digitalWrite(8, HIGH); //LOAD is made High and then Low
//delayMicroseconds(1);
digitalWrite(8, LOW);
}