Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod SD with Arduino Uno

Application notes for Pmod SD and Arduino Uno. In this app, voltages applied to inputs A0 & A1 are stored in a file on the SD card.

BeginnerProtip1 hour4,556
Using the Pmod SD with Arduino Uno

Things used in this project

Hardware components

Pmod SD
Digilent Pmod SD
×1
Arduino UNO
Arduino UNO
×1
Adafruit 8-channel Bi-directional Logic Level Converter - TXB0108
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Pmod SD and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod SD to the Arduino Uno.

Pmod SD and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod SD and Arduino Uno.

Code

Pmod SD and Arduino Uno Code

Arduino
Using this code will store the voltages applied to inputs A0 and A1 in a file on the SD card.
/************************************************************************
*
* Test of the Pmod
*
*************************************************************************
* Description: Pmod_SD
* The voltages applied to inputs A0 and A1 are stored in a file
* on the SD card.
*
* Material
* 1. Arduino Uno
* 2. Pmod SD 
* 3. Adafruit module TXB0108
*
************************************************************************/

#define CS 10 // Assignment of the CS pin
#include <SPI.h> // Call of libraries
#include <SD.h>
int tension;

void setup()
{
 Serial.begin(9600); // initialization of serial communication
 Serial.println("Initialisation carte SD");
 pinMode(CS, OUTPUT);
 // Initialisation carte SD
 if (!SD.begin(CS))
 {
  Serial.println(" * Carte absente");
  Serial.println(" * Erreur de cablage");
  return;
 }
 Serial.println("Carte initialisee.");
 delay(2000);
 
}

void loop()
{
 String donnee = ""; // String for storing values to be stored
 for (int i = 0; i < 2; i++) // conversion of voltage and addition to string
 {
  tension = analogRead(i);
  donnee+= String(tension);
  if (i < 1)
  {
   donnee += ","; // add comma between 2 data
  }
 }

 File fichier = SD.open("datalog.txt", FILE_WRITE); // open file datalog.txt
 if (fichier) // if the file is available
 {
  fichier.println(donnee); // write data in file
  fichier.close();
  Serial.println(donnee); // send data in serial monitor
 }
 else // if the file does not exist, display an error
 {
  Serial.println("Erreur d'ouverture fichier");
 }
 delay(1000); // wait 1 sec between metering and recording
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 20 followers
Alex Wong

Alex Wong

14 projects • 55 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments