Now that your card is ready to use, we can wire up the microSD breakout board! The breakout board we designed takes care of a lot for you. There's an onboard ultra-low dropout regulator that will convert voltages from 3.3V-6v down to ~3.3V (IC2). There's also a level shifter that will convert the interface logic from 3.3V-5V to 3.3V. That means you can use this board to interact with a 3.3V or 5V microcontrollers.
In this tutorial we will be using an Arduino to demonstrate the wiring and interfacing. If you have another microcontroller, you'll need to adapt the wiring and code to match!
Because SD cards require a lot of data transfer, they will give the best performance when connected up to the hardware SPI pins on a microcontroller. The hardware SPI pins are much faster than 'bit-banging' the interface code using another set of pins. For 'classic' Arduinos such as the Duemilanove/Diecimila/Uno those pins are digital 13 (SCK), 12 (MISO) and 11 (MOSI). You will also need a fourth pin for the 'chip/slave select' (SS) line. Traditionally this is pin 10 but you can actually use any pin you like. If you have a Mega, the pins are different! You'll want to use digital 50 (MISO), 51 (MOSI), 52 (SCK), and for the CS line, the most common pin is 53 (SS). Again, you can change the SS (pin 10 or 53) later but for now, stick with those pins.
- Connect the 5V pin to the 5V pin on the Arduino
- Connect the GND pin to the GND pin on the Arduino
- Connect CLK to pin 13 or 52
- Connect DO to pin 12 or 50
- Connect DI to pin 11 or 51
- Connect CS to pin 10 or 53
There's one more pin CD - this is the Card Detect pin. It shorts to ground when a card is not inserted. (Note that some card holders are the other way around). You should connect a pull up resistor (10K or so) and wire this to another pin if you want to detect when a card is inserted. We won't be using it for now.