So, I have made one project using a MAX 7219 (the led display 8x32) on my Arduino UNO, but it stopped working and I wanted to continue on a Arduino Due that I found. The problem is, the code utilizes the pins SCK, MOSI and SS ( CLOCK, DATA PIN and CHIP SELECT), that were the pins 13, 11 and 10 on the Arduino UNO.
Checking the pinouts of the Arduino DUE in some other posts, I have found that the SCK and MOSI are some pins in the middle of the board, where I need to use female jumpers to get them. The problem is, those pins doesn't have a "number" for then, they are just the SCK and MOSI itself. On the previous code I defined they by "#define CLK_PIN 13", how can I adjust the code so I can get that pinout?
I'm new to the forum and Arduino itself, so if I am saying things wrongs sorry for my misinformation... and for my bad english as well
You want to do this to figure out if the Uno failed or the max7219 failed? If the max7219 works with the Due you will know that the Uno has failed?
Can you test the Uno another way? Can you upload the blink sketch to it and have the on-board led flashing, for example?
What you need to find out is whether the code uses the hardware SPI of the Uno or is using software SPI ("bit-banging") but by coincidence is using the same pins as are normally used for hardware SPI.
If it is software SPI, then you can use any ordinary digital pins on the Due.
This makes me suspect that your code is using software SPI. It would not be necessary to define that pin if hardware SPI was used.
I actually wanted to continue the project on the DUE, because the capacity of the UNO was basically at its limit... But after the last upload on the code the UNO began to never upload anything at all and I am pretty worried about it. But the UNO was working perfectly fine with the code before.
On the Due while I was trying to make the code work on it, the max7219 is sometimes with all the led's off, sometimes all on, or just some 8x8 at a time. I don't know actually if the problem is on the code (and saying the right things abot the 3 pins - SCK, MOSI and SS) or the max7219, but before trying it on Due it was perfectly fine.
Ohhh understood, I did not know there was a difference there, the parts of using those pins of the display specifically I got from another code, so I assumed it was necessary to be those pins (the original code is actually written as "#define CS_PIN 10 // or SS", so I assumed it was the SS of the board that you are using. Is there a way for me to know if I am using a software SPI or the hardware SPI? I am just know learning about those and it's quite interesting.
Okay, I am gonna try using on 3 "random" pins on the DUE and see if it is gonna work.
Ohh I did not think of that, maybe that could be the problem cause the matrix even with everything on it sometimes experienced some instability.
Maybe that would fix the problem but I am still gonna try some other stuff and see if I can maybe make the code "kinda work" on it first
Thanks so much for the help
The only part of the code that actually uses these defined PINs is the mx and P below, so I don't know if they have a bigger influence on the rest of it just by being defined (I believe they don't have right??).
This define thing I got from another code so I don't know if it could be done other way or if it must be this way
Plus, I am not sure if the voltage thing is a problem because on the Arduino Due there is a pin (the 5V pin) that has a 4.5/4.8 DC on it (I used a multimeter) , so it has a voltage pretty similar right?
#include <MD_MAX72xx.h>
#include <MD_Parola.h>
#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW
#define MAX_DEVICES 4
#define CLK_PIN 13 // or SCK
#define DATA_PIN 11 // or MOSI
#define CS_PIN 10 // or SS
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
These definitions are not used anywhere in your code. Try searching for them and you will see. You can delete those lines, they have no effect on the code.
This must mean that the library is using hardware SPI. So you should use hardware SPI pins on the Due also. You don't need to update the code because they are different pins on the Due.
On the Due board there is no pin 78, nor 77, 86, 87!
If you use function calls from the SPI library you have to choose those calls with chip select pin as first parameter, e.g.
int cs_pin = 4; // or
...
SPI.begin(cs_pin);
SPI.transfer(cs_pin, 0xFF);
never use:
SPI.begin();
SPI.transfer(0xFF);
because without cs_pin as parameter BOARD_SPI_DEFAULT_SS will be used as chip select.
Are you sure? On some boards, pins will have multiple "Arduino Pin Numbers", depending on what function is being demanded of them. Since the g_aPinDescription type only lets a pin have a single function, usually.
For instance, looking at variant.cpp, there is an entry for "pin 86":