I have my (6) MAX7219 chips and LED matrix. I have a fully functional sketch that uses pins 12, 11, and 10 (Data out, CLK, and CS).
I am using a Nano 168 as my controller. Where I am putting this, it would make wiring so much easier if I could connect using the ICSP header instead of the actual pins.
If I have read up correctly, this is my conversion:
Change pin 10 to pin 13
My pin 12 = ICSP Pin 5
My pin 11 = ICSP Pin 1
My pin 13 = ICSP Pin 2
Power = ICSP Pin 6
GND = ICSP Pin 4
And then just daisy chain my 6 MAX7219 chips down the line. But by wiring in this manner, I must not use pins 11, 12, or 13 for anything else.
Are these the same? Can I write the code to use 11, 12, & 13, and connect to the ICSP header?
Or are they isolated? The other point I am trying to determine is the CS (or SS) pin. It does not seem to be on the ICSP header, and I don't think I can reconfigure "RESET" to be CS. But could I configure Pin 11 to be CS instead of MISO? I don't need MISO for my application.
I have not seen a schematic for a Nano 168, but assuming it's the same as a Nano 3 (atmega328) the SPI header will be connected to same exact same pins as you mentioned above. To do anything else would require complex circuitry to disconnect the SPI header pins, I can't imagine such circuitry would be used.
I don't think LedControl uses the hardware SPI interface, so you just have to tell it the new pin numbers and it will continue to work as it does now, bit-bashing the comms through the arbitrary pins.
There is a couple of orders of magnitude in speed increase if you use the hardware SPI interface (you need to include the SPI library and use it for SPI comms), so if the library does not support this it can't be done. Depending on your application it may make no difference. If you are frequently updating, then this is worth doing.
...so you just have to tell it the new pin numbers and it will continue to work as it does now...
...Depending on your application it may make no difference. If you are frequently updating, then this is worth doing.
Thanks! So i can set MOSI (Pin 12/ICSP pin 4) for Data Out, set SCK (Pin 13/ICSP pin 3) for Clock, and then set Pin 11/ICSP Pin 1 to be my CS and I will have all connections I need on the ICSP header.
Then that opens up pins 9 & 10 for PWM outputs.
My application is random LEDs on. Pure and simple. My delay time in the sketch is 10 [delay(10);]
I just need random LEDs to turn on and off of my 6 MAX7219 8x8 matrix displays. I'm not scrolling text, not worrying about which LED is on or off. Pure random.
Now, I will be adding (3) servo motors moving 0 to 90 degrees, again, pure random, as well as 2 more LEDs dimming and brightening. What this is doing is not critical, speed is not super important. And the servos are going to be delayed even more than just the LED updating.
delay(10); means 100 updates a second. With random leds this will look like they are all on all the time. You need to have at least 100ms between updates for your eyes to see the LED turn on and off, and the limits of human perception are generally around 200ms.
Once you add in the servos, please make sure you put them on a separate power supply or the whole thing will stop working due to power supply issues and you will be back on the forum asking why.
Oh power won't be an issue. But I understand the limitations.
As for the delay, I plan on tinkering with that. I think that value came from the very first time I got this sketch working with the MAX7219s, and the data rate was just so slow with 6 modules that it slowed itself down. If I remember right, when I first started, and was using just one MAX7219, I had my delay around 300-500, give or take, but as I stacked modules, I had to lower the delay.
To complete this question, yes. I was able to set my pins to use 11, 12, & 13 for MOSI, CS, and CLK and connect them to the ICSP header and they still work.
My pin assignment was a little off, but that was just trial and error to find the right layout.
Need not have been trial and error. Use a multimeter to measure the resistance between the pins of the ICSP and the pins on the Arduino header. Zero (or very low) resistance tells you the pins are connected, effectively one and the same.