I use SPI to drive a Ledstrip, however I only use the CLK (A3) and MOSI (A5). Is it possible to use the other pins (A2 (SS) and A4 (MISO)) for other purposes?
I have now a button on A4, however when using SPI the button keeps reading 0. So I suppose it’s because I’m using SPI.
When I don’t use SPI the pin reads out it’s values correctly.
@kasper, SPI.begin() will, by default, set A2 as an OUTPUT pin even if you don’t use it. Using SPI.begin(user CS pin) will set the pin you specify as CS as OUTPUT, leaving A2 unchanged. So in the first case, you need to set A2 after the begin() call and the other case, you can set before or after.
Sorry to re-open this. I’m doing my hardware design. I read different opinions about what to do with unused pins. I’d like to have the hardware as stable as possible (regarding EMC, EMI).
Some suggest to configure them as outputs and adding an external pull-down. Some as inputs with an external pull-down. There is also some information about the Startup default for different pins (a short LOW as I understood right).
I was wondering what is the correct thing to do with the SPI pins. Right now I configure them like that (from what I understood SPI.begin does it in that way as well).
I don’t use SPI2 right now but might use it in the future (but my hardware design needs to be ready for it).
pinMode(A2, OUTPUT); // unused SPI SS will be set as output
pinMode(A3, OUTPUT); // SPI SCK
pinMode(A4, INPUT); // unused SPI MISO
pinMode(A5, OUTPUT); // SPI MOSI
pinMode(D2, OUTPUT); // unused SPI2 MOSI
pinMode(D3, INPUT); // unused (SPI2 MISO)
pinMode(D4, OUTPUT); // unused SPI2 SCK
pinMode(D5, OUTPUT); // unused SPI2 SS