Saturday 7 July 2012

The SD Card


The next task is to interface a microSD with Arduino and play music files. The first thing to know about SD card is its pinout. 

SD CARD PINOUT
Te various pins are:
CS:         Chip Select
MOSI:   Master Out Slave In
GND:     Ground
VDD:      Supply pins
SCK:       Serial Clock
MISO:    Master In Slave Out
NC:          No Connect
IRQ:        Reserved

The SD card communicates using SPI mode of communication. Beginners dont have to worry about it much as the Arduino IDE provides a header file<SD.h> for the communication. All you need to know is the basic commands and the rest is IDE's job.

HARDWARE
For basic purposes , i don't think there is much of hardware required. All you need to do is connect MISO, MOSI, SCK and CS pins of SD to the respective pins of arduino. On arduino UNO we have: 
SCK:        pin 13
MISO:     pin 12
MOSI:     pin 11
CS:            pin 10
Also note that SD card works on 3.3V and Arduino on 5V, So we need to use an appropriate voltage divider circuit.The connection diagram is :


I had my own arduino shield with connections already made.
For playing music, we will need other cicuitary about which we'll discuss later.

SOFTWARE
I started with making .txt files and reading the ones already on it. I think <SD.h> is a very a nice library to help beginners read and write data to SD card. The SD library , by default creates an object called "SD". The various functions for this object are:
  1. begin()
  2. exists()
  3. mkdir()
  4. open()
  5. rmdir()
  6. remove()
These are a set of basic operations on SD card.
The various file operations are...
  1. available()
  2. flush()
  3. close()
  4. peek()
  5. print()
  6. pritln()
  7. seek()
  8. size()
  9. read()
  10. write()
  11. isDirectory()
  12. rewindDirectory()
The exact syntax of these functions is available on arduino playground
There are many test functions which give clear insight of how to play with SD Card.....

No comments:

Post a Comment