Arduino Leonardo and Logger Shield

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Arduino Leonardo and Logger Shield

Post by WhiteNite1971 »

Hi Gang

I have recently purchased a Arduino Leonardo and Logger Shield. Unfortunately these do not play well together. I thought I'd start a thread dedicated to working out how to resolve this.

The key issue revolves around the Serial Peripheral Interface (SPI) on the Arduino Leonardo. Specifically; the Arduino Leonardo does not have any SPI pins connected to digital pins 10 through to 13 which the Logger Shield requires.

To resolve this problem you need to download the following library;

https://github.com/adafruit/SD

//WARNING WARNING WILL ROBINSON!!!

It is at this stage I'm stuck. From what I've read I need to replace my SD library with the one above. I've searched everywhere to find where my 'installed' library is located but with no success. I can add new libraries no problem. :)

If I can get past this hurdle then what changes do I need to make to the following sample code to get the ball rolling;

Code: Select all

#include <SD.h>

void setup(){
  Serial.begin(9600);
  
  Serial.println("Check");
  pinMode(10, OUTPUT);
  
  if (!SD.begin(10)) {
    Serial.println("Fail");
    return;
  }
  Serial.println("Pass");
}

void loop(){
    File dataFile = SD.open("Test.txt", FILE_WRITE);
    if (dataFile){
      dataFile.println("Test");
      dataFile.close();
      Serial.println("Test");
      delay(5000);
    }
    else{
      Serial.println("Error");
    }
}
Any help would be greatly appreciated.

Cheers

Jase :)

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Leonardo and Logger Shield

Post by adafruit_support_bill »

You need to find where your Arduino installation folder is. It should be named something like "Arduino-1.0.3" (depending on the version). Inside that there should be a "Libraries" folder with all the standard libraries - including the SD library.

To use the "software-spi" in your code, you need to specify all the SPI pins in the "begin" function:

Code: Select all

  if (!SD.begin(10,11,12,13))

WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Re: Arduino Leonardo and Logger Shield

Post by WhiteNite1971 »

Hi adafruit_support

Thanks for getting back to me. For anyone attempting to do this, to get to your 'Existing Libraries Folder' on a Mac do the following;

1. Navigate to Applications Arduino
2. Control - Click Arduino
3. Click on Show Package Contents
4. File path Contents/Resources/Java/libraries

The original SD library is located here. Replace it with the one linked at the beginning of the thread.

Cheers

Jase

WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Re: Arduino Leonardo and Logger Shield

Post by WhiteNite1971 »

Hi Gang

I've changed the code as follows;

Code: Select all

#include <SD.h>

void setup(){
  Serial.begin(9600);
    while (!Serial) {
    ;
  }
  
  Serial.println("Check");
  pinMode(10, OUTPUT);
  
  if (!SD.begin(10,11,12,13)) {
    Serial.println("Fail");
    return;
  }
  Serial.println("Pass");
}

void loop(){
    File dataFile = SD.open("Test.txt", FILE_WRITE);
    if (dataFile){
      dataFile.println("Test");
      dataFile.close();
      Serial.println("Test");
      delay(5000);
    }
    else{
      Serial.println("Error");
    }
}
Unfortunately the serial monitor prints 'Fail' then 'Error'. The other curious thing is I'm unable to detect a voltage between GND and VIN.

Any thoughts?

Cheers

Jase

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Leonardo and Logger Shield

Post by adafruit_support_bill »

First thing: Have you verified the wave shield works on a standard Arduino? Have you tried different SD cards? Try the CardInfo sketch. It gives you a little more specific diagnostic information.

WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Re: Arduino Leonardo and Logger Shield

Post by WhiteNite1971 »

Hi adafruit_support

Again thanks for getting back to me. I have used the Logger Shield on an Arduino Uno and it works a treat! No issues at all :) . I then replaced the SD library as instructed and uploaded the amended sketch and for some odd reason it doesn't work. The reason I'm keen on using the Arduino Leonardo is that I also wish to emulate a keyboard (as well).

Any help would be greatly appreciated.

Cheers

Jase

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Leonardo and Logger Shield

Post by adafruit_support_bill »

Have you tried the Cardinfo sketch? What does it report?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”