
نوشته اصلی توسط
abdolhamednik
بخشی از کد رو بریدم
توی همون کد دیتا لاگر کافیه قسمت RFID رو برداری و ورودی تابعت رو به جای کاراکتر int تعریف کنی .
اینو تست کن:
کد:
#include <SD.h>
#include <SPI.h>
#define SS_PIN 9
#define RST_PIN 3
void setup()
{
SPI.begin(); // Init SPI bus
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
if (!SD.begin(10)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop()
{
writeFile(125);
}
void rfidData(){
}
void writeFile(int data){
File myFile;
Serial.print("Saving data: ");
myFile = SD.open("data2.txt", FILE_WRITE);
// Serial.println(data);
myFile.println(data);
delay(50);
myFile.close();
Serial.println(data);
}