Sie sind auf Seite 1von 5

SD CARD WRITE PROGRAM

THE HOST MESSAGE PROGRAM-

String cha= "";

void setup(){

Serial.begin(9600);

void loop(){

cha ="--------------------------------------------- STACK VOLTAGE 3871818 | 3841300 | 3852134 |


4226590 | 3854575 | 4122371 | 3865867 | 3854575 | 3852897 | 3861900|3837943
| 3935448 @SOC - 117 @VOLTAGE ALERT CONDITION 5749 C 5109 C 3888 C 5066 C
@CHARGING CURRENT : 3205 mA ---------------------------------------------@";

Serial.print(cha);

THE RECIEVER PROGRAM-

#include <SD.h>

#include <SPI.h>

File myFile;
int pinCS = 53; // Pin 10 on Arduino Uno

char b;

char a[6000]= "";

void setup() {

Serial.begin(9600);

Serial1.begin(9600);

pinMode(pinCS, OUTPUT);

///////////////////////////////////////////////////////////////////////// SD Card Initialization

if (SD.begin())

Serial.println("SD card is ready to use.");

else

Serial.println("SD card initialization failed");

return;

}
}

void loop()

myFile = SD.open("test.txt", FILE_WRITE);

if (myFile) {

for(unsigned int i=0; i<6000;i++)

if (Serial1.available()){

b = Serial1.read();

a[i]=b;

Serial.print(a[i]);

myFile.print(a[i]);

if (b == 64){

Serial.println("");

myFile.println("");

}
}

myFile.close(); // close the file

else {

Serial.println("error opening file");

delay(2000);

CONNECTIONS PHOTO-

Das könnte Ihnen auch gefallen