my Arduino nono probelm with sd module

my Arduino nono probelm with sd module.it shows intialization failed .i have formated the sd before use.
MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
i have connected like this and use the example read write file

Do you have pin 10 set as OUTPUT in setup() as is required for SPI to work as a master?

All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.

From:

https://www.arduino.cc/en/Reference/SPI

no pin 10 is reserved for other component

Thachuthas:
no pin 10 is reserved for other component

For your Arduino to act as SPI master, its own slave select pin has to be set as an output.

Pin 10 can be used for another purpose as long as it is set to OUTPUT. If you need an input you will need to switch to another pin and set pin 10 to OUTPUT. The analog pins can be used for digital input if you are out of regular digital pins.

groundfungus:
if you are out of regular digital pins.

I think OP posted eleswhere that he even wants to use pins 0 and 1, and all the Ax pins, so he's on the limit here.

groundfungus:
Pin 10 can be used for another purpose as long as it is set to OUTPUT.

So just for my clarity then, as long as it's an OUTPUT, it can be digitalWrite'd HIGH and LOW as desired with no confusion to the SPI?

So just for my clarity then, as long as it's an OUTPUT, it can be digitalWrite'd HIGH and LOW as desired with no confusion to the SPI?

That is my understanding. I'll try to find corroboration.

Here we go:

Basically, do whatever you want with pin 10 during SPI, as long as you don’t turn it into an Input.

from:

/*
  SD card read/write

 This example shows how to read and write data to and from an SD card file
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4

 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}

where to put pin 10 as output

void setup() {
  pinMode(10, OUTPUT);  //  SS pin to output
 
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

groundfungus:
Here we go

Thanks.

groundfungus:

void setup() {

pinMode(10, OUTPUT);  //  SS pin to output

// Open serial communications and wait for port to open:
  Serial.begin(9600);

but it still dont work
plz help me to pin connection

I see that you are using an example right from the SD library. That should work without explicitly setting pin 10 to output as that is done by the library. As long as it is not changed later it should be OK. The best that I can suggest is try a different card and carefully check your wiring. I have had trouble with some cards not working. Is the SD card module all that is connected to your Arduino?

this sd module worked with mu arduino uno