This sketch continually tries to access an SD card on the North face using the 'IXM SD Cell' connectivity pattern. When it finds one, it reports the number of 512 byte blocks the card has, then switches to just checking that the card is still there.

For this sample output, I first popped in and out a 2GB SanDisk card. Later, I put in a 4GB card:

  Ln 18.137 Card found!  Block count = 3862528
  Ln 24.143 Card lost.  Ending.
  Ln 39.821 Card found!  Block count = 7563000

// SD Card 1: Detect SD cards to the North, report their size

#include "SFBSDRaw.h"           // Explicitly access the SDRaw library

SDRaw mySD;                     // Allocate space for a raw sdcard controller

void setup() {
  mySD.begin(NORTH);            // Set up for 'IXM SD Cell' connectivity on East

void loop() { 
  u8 led = BODY_RGB_GREEN_PIN;  // Assume we have a card

  if (!mySD.isActive()) {       // If controller is inactive, try to..

    if (mySD.init())            // ..initialize it
      logNormal("Card found!  Block count = %d\n", mySD.getBlockCount());
      led = BODY_RGB_RED_PIN;   // Or blink red if still no card yet

  } else {                      // If controller is active, just check card status

    if (mySD.readStatus() != 0) { // which should be zero.  If not, end the session.
      logNormal("Card lost.  Ending.\n");

  ledOn(led);  delay(1000);     // Blink green or red
  ledOff(led); delay(1000);     

Generated on Fri Apr 22 06:54:11 2011 for SFB by doxygen 1.5.9