0% found this document useful (0 votes)
669 views

Arduino Extended Database Library Using An SD Card

This document summarizes how to use the Extended Database Library with an SD card on an Arduino. It explains that the library allows for non-volatile storage of byte-level data that can be read and written. The example shows how to initialize an SD card, create a database file, add and read records from the file using the library functions. Notes are provided about compatibility with different Arduino boards.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
669 views

Arduino Extended Database Library Using An SD Card

This document summarizes how to use the Extended Database Library with an SD card on an Arduino. It explains that the library allows for non-volatile storage of byte-level data that can be read and written. The example shows how to initialize an SD card, create a database file, add and read records from the file using the library functions. Notes are provided about compatibility with different Arduino boards.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Arduino Extended Database Library using

an SD Card
The Arduino Playground Site of the Extended Database Library states that : With these changes,
it is now ossible to use this library in con!unction with the standard Arduino EEP"#$ library,
an external EEP"#$ such as the AT%&'()%&, ro*iding (%+ , -(% .ilobytes of non/*olatile
storage, or any other latfor0 that suorts byte le*el reading and writing such as an SD card12
3ut unfortunately 4 didn5t find any exa0le in the internet that shows how to use the library with
an SD 'ard1 4n the following is 0y *ersion of the sulied ED36Si0le using an SD 'ard
instead of the build/in EEP"#$1 7or learning how to connect an SD 'ard Writer8"eader to an
Arduino there are a lot of exa0les around1 $y Exa0le is for an Arduino 9:# with a chea
SD 0odule hardwired to P4: () ;Those 0odules do not wor. on the newer Arduinos<1 40ortant
are the reader and writer functions and that you ha*e to create a file and use the see.;< 0ethod1
PLEASE :#TE= 3E>4::4:> W4T? A"D94:# (1) @#9 ?AAE T# '?A:>E '#DE 4:
ED31'PP ;T?E L43"A"@<: Binclude WProgra01h2 has to be chanced to Binclude
Arduino1h21
#include "Arduino.h"
#include <EDB.h>
#include <SD.h>

File dbFile;

#define TABLE_SIZE 5!
#define "E#$"DS_T$_#"EATE %

&'ruc' Lo(E)en' *
in' id;
in' 'e+,er-'ure;
.
lo(E)en';

)oid /ri'er0un&i(ned lon( -ddre&&1 b2'e d-'-3
*
dbFile.&ee40-ddre&&3;
dbFile./ri'e0d-'-3;
dbFile.flu&h03;
.

b2'e re-der0un&i(ned lon( -ddre&&3
*
dbFile.&ee40-ddre&&3;
re'urn dbFile.re-d03;
.
EDB db05/ri'er1 5re-der3;

)oid &e'u,03
*
Seri-l.be(in067%%3;

Seri-l.,rin'0"Ini'i-li8in( SD c-rd..."3;

,in9ode0%1 $:T;:T3;

if 0<SD.be(in033 *
Seri-l.,rin'ln0"ini'i-li8-'ion f-iled<"3;
re'urn;
.

Seri-l.,rin'ln0"ini'i-li8-'ion done."3;

Seri-l.,rin'ln0"$,enin( e=-+,le.db ..."3;
dbFile > SD.o,en0"e=-+,le.db"1 FILE_?"ITE3;

db.cre-'e0%1 TABLE_SIZE1 &i8eof0lo(E)en'33;

Seri-l.,rin'0""ecord #oun'@ "3; Seri-l.,rin'ln0db.coun'033;

Seri-l.,rin'ln0"#re-'in( "ecord&..."3;
in' recno;
for 0recno > ; recno <> "E#$"DS_T$_#"EATE; recnoAA3
*
lo(E)en'.id > recno;
lo(E)en'.'e+,er-'ure > recno B !;
db.-,,end"ec0EDB_"E# lo(E)en'3;
.

Seri-l.,rin'0""ecord #oun'@ "3; Seri-l.,rin'ln0db.coun'033;
for 0recno > ; recno < "E#$"DS_T$_#"EATE; recnoAA3
*
db.re-d"ec0recno1 EDB_"E# lo(E)en'3;
Seri-l.,rin'0"ID@ "3; Seri-l.,rin'ln0lo(E)en'.id3;
Seri-l.,rin'0"Te+,@ "3; Seri-l.,rin'ln0lo(E)en'.'e+,er-'ure3;
.
.


)oid loo,03
*

.

You might also like