int digitalPotWriteRed(int value)
{
digitalWrite(CS1, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS1, HIGH);
} int digitalPotWriteGreen(int value)
{
digitalWrite(CS2, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS2, HIGH);
}
...
search term: arduino multiple SPI
bottom line: you have to turn one CS off, then turn the other one on. either, or the other, not both
http://www.learningaboutelectronics.com/Articles/Multiple-SPI-devices-to-an-arduino-microcontroller.php
In this case the usual suspect is the SD card module. You should check that your SD card module correctly handles the SPI bus signals. It's usually the MISO signal that is causing the problems, which only becomes apparent when a 2nd device is added to the SPI bus.
Search the forums and you should find several discussions on the subject along with solutions.
You are right. I also think SD Card module is making the problem. I have spent a lot of time to fix it. And i could not find the solution on internet also. But I gonna spend some more time with it.
From memory, the solution was for the MISO signal to bypass the "level shifting" chip. Something like: Lift the MISO signal pin on the chip on the header side and route the MISO signal direct from the SD card socket to the header. Note that there may have been a diode in there as well.
A search for "arduino sd card miso fix" via google will bring up many discussions.