Devices & Components
Arduino Due
Hardware & Tools
SDCard shield
Software & Tools
Processing
Project description
Code
Code for save data in SDcard
c_cpp
This code is for to save data from ADC in SDcard
1/* 2 SD card datalogger 3 4 This example shows how to log data from three analog sensors 5 to an SD card using the SD library. 6 7 The circuit: 8 * analog sensors on analog ins 0, 1, and 2 9 * SD card attached to SPI bus as follows: 10 ** MOSI - pin 11 11 ** MISO - pin 12 12 ** CLK - pin 13 13 ** CS - pin 4 14 15 created 24 Nov 2010 16 modified 9 Apr 2012 17 by Tom Igoe 18 19 This example code is in the public domain. 20 21 */ 22 23#include <SPI.h> 24#include <SD.h> 25 26const int chipSelect = 4; 27 28void setup() { 29 // Open serial communications and wait for port to open: 30 Serial.begin(9600); 31 while (!Serial) { 32 ; // wait for serial port to connect. Needed for native USB port only 33 } 34 35 36 Serial.print("Initializing SD card..."); 37 38 // see if the card is present and can be initialized: 39 if (!SD.begin(chipSelect)) { 40 Serial.println("Card failed, or not present"); 41 // don't do anything more: 42 return; 43 } 44 Serial.println("card initialized."); 45 46 File dataFile = SD.open("electro2.txt", FILE_WRITE); 47 48 49for (int i = 0; i < 2000; i++) 50 51 { 52 53String dataString = ""; 54 55//dataString += String(i); 56//dataString += ","; 57 int sensor = analogRead(0); 58 dataString += String(sensor); 59 60 dataFile.println(dataString); 61 62 /* 63 if (dataFile) { 64 dataFile.println(dataString); 65 dataFile.close(); 66 // print to the serial port too: 67 //Serial.println(dataString); 68 }*/ 69 70 71delay(1); 72} 73 dataFile.close(); 74 75 76Serial.println("Archivo cerrado"); 77 78} 79 80 81 82void loop() { 83 84} 85 86 87 88 89 90 91 92 93 94
Code for save data in SDcard
c_cpp
This code is for to save data from ADC in SDcard
1/* 2 SD card datalogger 3 4 This example shows how to log data 5 from three analog sensors 6 to an SD card using the SD library. 7 8 The circuit: 9 10 * analog sensors on analog ins 0, 1, and 2 11 * SD card attached to SPI bus as 12 follows: 13 ** MOSI - pin 11 14 ** MISO - pin 12 15 ** CLK - pin 13 16 ** CS 17 - pin 4 18 19 created 24 Nov 2010 20 modified 9 Apr 2012 21 by Tom Igoe 22 23 24 This example code is in the public domain. 25 26 */ 27 28#include <SPI.h> 29#include 30 <SD.h> 31 32const int chipSelect = 4; 33 34void setup() { 35 // Open serial 36 communications and wait for port to open: 37 Serial.begin(9600); 38 while (!Serial) 39 { 40 ; // wait for serial port to connect. Needed for native USB port only 41 42 } 43 44 45 Serial.print("Initializing SD card..."); 46 47 // see if the 48 card is present and can be initialized: 49 if (!SD.begin(chipSelect)) { 50 Serial.println("Card 51 failed, or not present"); 52 // don't do anything more: 53 return; 54 55 } 56 Serial.println("card initialized."); 57 58 File dataFile = SD.open("electro2.txt", 59 FILE_WRITE); 60 61 62for (int i = 0; i < 2000; i++) 63 64 { 65 66String 67 dataString = ""; 68 69//dataString += String(i); 70//dataString += ","; 71 72 int sensor = analogRead(0); 73 dataString += String(sensor); 74 75 dataFile.println(dataString); 76 77 78 /* 79 if (dataFile) { 80 dataFile.println(dataString); 81 dataFile.close(); 82 83 // print to the serial port too: 84 //Serial.println(dataString); 85 }*/ 86 87 88 89delay(1); 90} 91 dataFile.close(); 92 93 94Serial.println("Archivo 95 cerrado"); 96 97} 98 99 100 101void loop() { 102 103} 104 105 106 107 108 109 110 111 112 113
Downloadable files
SD card connection
SD card connection

SD card connection
SD card connection

Experiment Setup
This image shows the ecg simulator and Arduino connected to ECG shield. This experiment setup was used for to simulate the ECG signal acquisition and signal storage in SD card.
Experiment Setup

Documentation
ECG SHIEDL olimex
This is the ECG shield From Olimex used as analog amplifier.
ECG SHIEDL olimex

Arduino due and SDcard
This image is from: https://hackaday.io/project/19560-arduino-due-cpm-personal-computer
Arduino due and SDcard

ECG SHIEDL olimex
This is the ECG shield From Olimex used as analog amplifier.
ECG SHIEDL olimex

Arduino due and SDcard
This image is from: https://hackaday.io/project/19560-arduino-due-cpm-personal-computer
Arduino due and SDcard

Comments
Only logged in users can leave comments