Go Down

Topic: SD problem with Double Write or Double Read (Read 940 times) previous topic - next topic

DeanCC

Another newbie likely simple problem.  I'm learning how to use my just arrived SD shield from Adafruit. Got it going (yea !) but... I'm getting a double write or a double read from a single text line entry onto the file I'm creating on the SD card  .I can't determine if its a double write problem or a double read problem.  I am using the example codes from the downloads I have.
I've tried different approaches to writing and reading after erasing the text file and redoing the read / write attempts. I write one line , then quit the program. I read one line then quite the program. Each time it shows two entries. There are no loops involved when reading or writing the single line of text to the SD card. Smells like a problem with the actual way the text file structure is written or read. But probably its just something bonehead I'm doing wrong that everybody knows about.
Using Arduino Uno , and only the SD shield.
If this is something I could have read about in the blog hx's here I apologize.

DeanCC

I've been playing with the SD card and software. The code seems to write to the SD card once, but there are two lines of text on the file instead of one. I'm guessing I'm doing something wrong with the statement" SD.begin(number) ". I'm probably not using the pins right. The software comes with number=4. This doesnt work. I subsituted "10" and the program worked but writes two lines of characters to the SD File instead of one. Obviously I don't understand the use of digital pins for communicating with and selecting the SD card.My best guess. Suggestions ? i'm learning.

DeanCC

Soo....... I continued merrily on with my new SD shield and wrote a timestamp program with the RealTime Clock chip for my project. I noticed that the duplicate entries stamped with the time were about 5 seconds apart. Apparently the SD shield needs downtime between MyFile.println; statements when embedded in an If (.......){MyFile.println();} statement. I threw in some delay() statements.  Problem fixed but what do I need to know about what I'm doing ? Sorry the shield didn't come with a programming book just code examples.
 
 Any takers ?
Newbie

Gdunge

Sorry, we can't tell you what's wrong with your code if we haven't seen it. Please post some code that we can critique.

Here's how to best use this forum:

http://forum.arduino.cc/index.php?topic=149023.0

TL;DR - please write and post a small program that only demonstrates the problem you are having, so we don't have to wade through piles of irrelevant code.

Go Up