Yes, the wiring is different to use the ATMega SPI hardware.
What you haven't done is set up any of the registers:
digitalWrite (10,LOW);
SPI.transfer (insert_register_name_ADDRESS); //
SPI.transfer (0x0C); // and value
digitalWrite (10, HIGH);
for these registers:
DECODE_MODE 0x09 // write data 0xFF, Code B Decode for all digits << You will set this for No Decode mode instead - FIND VALUE IN THE DATASHEET
INTENSITY_ADDRESS 0x0A // 0x07 to start, half intensity. valid from 0x00 (min) to 0x0F (max)
SCANLIMIT_ADDRESS 0x0B // 0xFF, all 8 digits on
SHUTDOWN_ADDRESS 0x0C // 0x01, normal operation (0x01 = shutdown) - powers up in shutdown mode
DISPLAYTEST_ADDRESS 0x0F // 0x01 = all lights on full, 0x00 = normal ops
and then write the data you actually want to appear in these registers, which controls what appears at the LEDs (outside of writing a 1 to DISPLAYTEST_ADDRESS which turns them all on for a test):
register1 0x01 // digit 0
register2 0x02 // digit 1
register3 0x03 // digit 2
register4 0x04 // digit 3
register5 0x05 // digit 4
register6 0x06 // digit 5
register7 0x07 // digit 6
register8 0x08 // digit 7
So put the register in an array so you can reference them, and make an array to hold your display pattern
byte register [ ] = {0,1,2,3,4,5,6,7};
byte registerdata [ ] = {B00000001,B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000}; // initialize with some data
Next, have a group of these in void setup to set up the control registers - each register!
digitalWrite (10,LOW);
SPI.transfer (insert_register_name_ADDRESS); //
SPI.transfer (0x0C); // and value
digitalWrite (10, HIGH);
and in void loop, write the data from an array that contains the LED pattern you want to see:
void loop(){
if (display_update == 1){ //see if "decision code" has made changes to the array
// clear flag for next pass
display_update = 0;
// now do the transfers to update the '7221 registers
for (x=0, x<8; x=x+1){
digitalWrite (10,LOW);
SPI.transfer (register[x]); // register to write to
SPI.transfer (registerdata[x]); // and value
digitalWrite (10, HIGH);
}
// "decision code"
// change registerdata[ ] based on elapsed time, buttons pressed, predefined sequence, whatever
:
:
// when all done set the update flag:
display_update = 1;
}