SD Card module with Arduino Uno

The SD card module is especially useful for projects that require data logging. The Arduino can create a file in an SD card to write and save data using the SD library. There are different models from different suppliers, but they all work in a similar way, using the SPI communication protocol.
This Micro SD Card is used for transfering data to and from a standard sd card. The pin out is directly compatible with Arduino and also can be used with other microcontrollers. It allow us to add mass storage and data logging to our project.
Micro SD Card Module
1. CS (chip select)
2. SCK (serial clock)
3. MOSI (master out slave in)
4. VCC (3.3V or 5V)
5. GND (ground)
a. Input Voltage: 3.3V/5V
b. With all SD SPI Pins out :MOSI, SCK, MISO and CS ,for further connection
c. Through programming, you can read and write to the SD card using your arduino
d. Make your SD application more easier and simple
e. Communicate with Arduino using SPI interface
f. Push-pop socket with card slightly over the edge of the PCB so its easy to insert and remove
g. 4 mounting holes with 2.2mm diameter
h. Only use 4 I/O pins on the Arduino
i. Size: 42mm x 25mm x 5mm

Vcc 3.3 to 5V DC
CS 4
CLK 13
GND Ground of Arduino Board

This module uses the standard SPI interface for communication, which involve SPI buses, MISO, MOSI, SCK, and a CS signal pin. through programming, the data can easily be read and wrote into SD Card by using the Arduino or other microcontrollers.
Copy and paste or download below given link:
// is an automatic generator of schematics and code.
//Copyright (C) 2016 Roboplan Technologies Ltd.
// Include Libraries
#include “Arduino.h”
#include “SD.h”
// Pin Definitions
#define SDFILE_PIN_CS 10
// Global variables and defines
// object initialization
File sdFile;
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
while (!Serial) ; // wait for serial port to connect. Needed for native USB
// Set SPI SS pin to output otherwise the SD library functions will not work.
// The SD is set to use SPI SS Arduino pin 10 as chip select(CS) by default.
// To change the pin use SD.begin(SD_CS_PIN)
// Check if the card is present and can be initialized
if (!SD.begin()) {
Serial.println(F(“Card failed, or not present”));
Serial.println(F(“card initialized.”));
menuOption = menu();
// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
if(menuOption == ‘1’)
// Micro SD Card Memory Shield Module – Test Code
// The SD example code creates a datalog.txt file for logging sensor data
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
sdFile =“datalog.txt”, FILE_WRITE);
// if the file exists in SD card, write sensor data
if (sdFile) {
//Write to file
sdFile.println(“ENTER SENSOR DATA HERE”);
// close the file
// Uncomment to print to the serial port
//Serial.println(“ENTER SENSOR DATA HERE”);
else {
// if the file didn’t open, print an error
Serial.println(F(“error opening file.”));
if (millis() – time0 > timeout)
menuOption = menu();
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
Serial.println(F(“\nWhich component would you like to test?”));
Serial.println(F(“(1) Micro SD Card Memory Shield Module”));
Serial.println(F(“(menu) send anything else or press on board reset button\n”));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
char c =;
if (isAlphaNumeric(c))
if(c == ‘1’)
Serial.println(F(“Now Testing Micro SD Card Memory Shield Module”));
Serial.println(F(“illegal input!”));
return 0;
time0 = millis();
return c;
Download SD Card Arduino code: Here.SD card with arduino

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.