hi i want some question about sending integer from sd card to arduino!!
but the receive data is not same as text file..
255
200
50
100
230
150
55
190
50
255
200
50 <--- text file
255
300
50
2
150
990
58
255
200
50
255
300 <--- serial monitor
and this is my code
#include <SD.h>
#include<SPI.h>
File myFile;
int ledPin = 2;
String str;
int disp;
Sd2Card card;
SdVolume volume;
SdFile root;
const int chipSelect = 4;
void setup() {
Serial.begin(2000000);
pinMode(10, OUTPUT);
pinMode(ledPin, OUTPUT);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
}
void loop(void) {
myFile = SD.open("DATA.txt",FILE_READ);
while(myFile.available()){
str = myFile.readStringUntil('\n');
char ch[3] = {0};
str.toCharArray(ch,str.length());
disp = atoi(ch);
Serial.println(disp);
analogWrite(ledPin,disp);
delay(1000);
}
myFile.close();
}
i don't know how to solve this problem. please help....