Thank you.
I think your code does my first half of my work...i really appreciate if u give any hint how to send data(which is read from text file) from sd card to arduino using spi.
ashritha:
I think your code does my first half of my work...i really appreciate if u give any hint how to send data(which is read from text file) from sd card to arduino using spi.
#include <SD.h>
#include <SPI.h>
File file;
const int chipSelect = 10; /*for arduino*/
const int ss = 9; /*for sdcard*/
void setup() {
Serial.begin(57600); //Begin serial communication
SPI.begin();
pinMode (10,OUTPUT);
if (!SD.begin(9)) { //Check that SD card is initialized
Serial.println("SD not initialized");
return;
}
else {
Serial.println("SD initialized");
}
file = SD.open("logdata.txt"); //Open file
if(file) {
Serial.println("File opened");
while (file.available()) {
char c = file.read();
Serial.write(c);
digitalWrite(SS, LOW);
SPI.transfer(c);
digitalWrite(SS, HIGH);
}
}
else
Serial.println("File failed to open");
}
void loop() {
digitalWrite(chipselect, HIGH); // ensure SS stays high
// Put SCK, MOSI, SS pins into output mode
// also put SCK, MOSI into LOW state, and SS into HIGH state.
// Then put SPI hardware into Master mode and turn SPI on
SPI.begin ();
delay (5000); // 5 seconds delay to start logic analyser.
char c;
// enable Slave Select
digitalWrite(chipselect, LOW); // SS is pin 10
// send test string
for (const char * p = "h/n" ; c = *p; p++)
SPI.transfer (c);
// disable Slave Select
digitalWrite(chipselect, HIGH);
// turn SPI hardware off
SPI.end ();
while (1); //loop
}