카드 모듈을 사용하여 Arduino Mega 2560의 직렬 포트에서 SD 카드로 쓰려고합니다.직렬 포트에서 SD 카드로 쓰기
내가 직렬 COM에서 입력 한 내용을 txt 파일에 기록 할 수 있기를 원합니다.
#include <SPI.h>
#include <SD.h>
const int chipSelect = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.print("This is a test and should be ignored");
if (!SD.begin(chipSelect)) {
Serial.println("\nCard failed, or not present");
// don't do anything more:
return;
}
else{
Serial.println("\ncard initialized.");
}
}
void loop() {
// put your main code here, to run repeatedly
File OpenFile = SD.open("test.txt", FILE_WRITE);
if(OpenFile and Serial.available());
{
OpenFile.println(Serial1.read());
OpenFile.close();
}
}
그러나의 연속 선 "-1"과 "1"을 "은 SD에 기록하지 않고.
예, 다른 방법을 통해 SD 카드에 쓸 수 있어요. ..
건배, 팝
효과가있었습니다. 하지만 그것은 ASCII로되어 있습니다 (Code는 다른 comp ...에 있습니다). 누구든지 장래에 도움이 필요한 경우 serial.read를 char로 구문 분석해야합니다. – PoP
@PoP 답변으로 질문을 해결할 수 있다면 투표를 추가하거나 답변으로 선택하는 것이 좋습니다. 건배 –