را اندازی ماژول رم خوان مدل:
ماژول کارتخوان میکرو SD - ماژول میکرو اس دی Micro-SD/TF --- H5A2
//Program by Amir Alizade
// Micro-SD/TF H5A2
#include <SD.h> //SD Card Library
#include <SPI.h>
//SPI SD Card Pins
//VCC = PIN 8
//CS = PIN 10
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
//GND = PIN 14
int CS_pin = 10;
int pow_pin = 8;
long counter = -1; //Use this to store the Counter#
void setup()
{
Serial.begin(9600);
Serial.println("serial set at 9600 baud");
//CS Pin is an output
pinMode(CS_pin, OUTPUT);
Serial.println("CS_pin set as OUTPUT");
//SD Card will Draw Power from Pin 8, so set it high
pinMode(pow_pin, OUTPUT);
digitalWrite(pow_pin, HIGH);
Serial.println("pow-pin 8 set as OUTPUT and HIGH");
//Initialize SD Card with CS_pin = 10
if (!SD.begin(CS_pin))
{
Serial.println("Card Failure - CS_pin 10 no signal");
return;
}
Serial.println("Card Ready - Signal on CS_pin 10");
SD.remove("LOG.amr");
File logFile = SD.open("LOG.amr", FILE_WRITE);
Serial.println("opened LOG.amr file");
if (logFile)
{
logFile.println("Test");
Serial.println("Start Writing to LOG.amr");
}
else
Serial.println("Couldn't open LOG.amr file");
}
void loop()
{
File logFile = SD.open("LOG.amr", FILE_WRITE);
if (logFile)
{
logFile.println( String(++counter));
Serial.println( String(counter));
}
else
Serial.println("Couldn't open log file");
logFile.close();
}