<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ko">
	<id>https://arduwiki.com/html/index.php?action=history&amp;feed=atom&amp;title=SD_Card_Module</id>
	<title>SD Card Module - 편집 역사</title>
	<link rel="self" type="application/atom+xml" href="https://arduwiki.com/html/index.php?action=history&amp;feed=atom&amp;title=SD_Card_Module"/>
	<link rel="alternate" type="text/html" href="https://arduwiki.com/html/index.php?title=SD_Card_Module&amp;action=history"/>
	<updated>2026-04-29T02:09:32Z</updated>
	<subtitle>이 문서의 편집 역사</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://arduwiki.com/html/index.php?title=SD_Card_Module&amp;diff=2557&amp;oldid=prev</id>
		<title>2025년 3월 27일 (목) 12:13에 ArduWiki님의 편집</title>
		<link rel="alternate" type="text/html" href="https://arduwiki.com/html/index.php?title=SD_Card_Module&amp;diff=2557&amp;oldid=prev"/>
		<updated>2025-03-27T12:13:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ko&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 이전 판&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2025년 3월 27일 (목) 21:13 판&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l247&quot;&gt;247번째 줄:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;247번째 줄:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The serial monitor displays &amp;quot;Data recording completed,&amp;quot; and when you connect the SD card to the PC, you will find the previously created TEXT.txt file along with the newly recorded MOISTURE.txt file. You can confirm that the MOISTURE.txt file contains data from the soil moisture sensor (YL-69).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The serial monitor displays &amp;quot;Data recording completed,&amp;quot; and when you connect the SD card to the PC, you will find the previously created TEXT.txt file along with the newly recorded MOISTURE.txt file. You can confirm that the MOISTURE.txt file contains data from the soil moisture sensor (YL-69).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[파일:SD카드모듈예제4결과.jpg|가운데|class=coders100]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[파일:SD카드모듈예제4결과.jpg|가운데|class=coders100]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== &#039;&#039;&#039;Purchase Link&#039;&#039;&#039; ==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[https://gongzipsa.com/shop/1717136808 GONGZIPSA]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key arduwiki:diff::1.12:old-1761:rev-2557 --&gt;
&lt;/table&gt;</summary>
		<author><name>ArduWiki</name></author>
	</entry>
	<entry>
		<id>https://arduwiki.com/html/index.php?title=SD_Card_Module&amp;diff=1761&amp;oldid=prev</id>
		<title>ArduWiki: /* 4. Logging Sensor Data */</title>
		<link rel="alternate" type="text/html" href="https://arduwiki.com/html/index.php?title=SD_Card_Module&amp;diff=1761&amp;oldid=prev"/>
		<updated>2024-08-09T09:04:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;4. Logging Sensor Data&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ko&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 이전 판&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2024년 8월 9일 (금) 18:04 판&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l205&quot;&gt;205번째 줄:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;205번째 줄:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== 4. Logging Sensor Data ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== 4. Logging Sensor Data ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is an example of recording data from the [[Soil Moisture Sensor(YL-69)]] every 3 seconds and saving it to the SD card.&amp;lt;syntaxhighlight lang=&quot;c++&quot; line=&quot;1&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is an example of recording data from the [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Soil moisture sensor(YL-69)|&lt;/ins&gt;Soil Moisture Sensor(YL-69)]] every 3 seconds and saving it to the SD card.&amp;lt;syntaxhighlight lang=&quot;c++&quot; line=&quot;1&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;SPI.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;SPI.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;SD.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;SD.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key arduwiki:diff::1.12:old-1760:rev-1761 --&gt;
&lt;/table&gt;</summary>
		<author><name>ArduWiki</name></author>
	</entry>
	<entry>
		<id>https://arduwiki.com/html/index.php?title=SD_Card_Module&amp;diff=1760&amp;oldid=prev</id>
		<title>ArduWiki: 새 문서: {{#seo:|title=Arduwiki : Arduino SD Card Module Guide|title_mode=append|keywords=Arduino, Information Science, Maker Learning, Performance Assessment, SD Card Module, Arduino Project, Capstone Project, Arduino Example Code|description=This introduces how to control a SD Card Module with Arduino (basic information, circuit, example code). It can be used in Information Science and Maker classes.}}  파일:아두이노 SD 카드 모듈 대표이미지1.jpg|가운데|class=coders1...</title>
		<link rel="alternate" type="text/html" href="https://arduwiki.com/html/index.php?title=SD_Card_Module&amp;diff=1760&amp;oldid=prev"/>
		<updated>2024-08-09T09:02:44Z</updated>

		<summary type="html">&lt;p&gt;새 문서: {{#seo:|title=Arduwiki : Arduino SD Card Module Guide|title_mode=append|keywords=Arduino, Information Science, Maker Learning, Performance Assessment, SD Card Module, Arduino Project, Capstone Project, Arduino Example Code|description=This introduces how to control a SD Card Module with Arduino (basic information, circuit, example code). It can be used in Information Science and Maker classes.}}  파일:아두이노 SD 카드 모듈 대표이미지1.jpg|가운데|class=coders1...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;새 문서&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{#seo:|title=Arduwiki : Arduino SD Card Module Guide|title_mode=append|keywords=Arduino, Information Science, Maker Learning, Performance Assessment, SD Card Module, Arduino Project, Capstone Project, Arduino Example Code|description=This introduces how to control a SD Card Module with Arduino (basic information, circuit, example code). It can be used in Information Science and Maker classes.}}&lt;br /&gt;
&lt;br /&gt;
[[파일:아두이노 SD 카드 모듈 대표이미지1.jpg|가운데|class=coders100]]&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Overview&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
The Arduino SD card module is an interface module compatible with Arduino boards that allows reading from and writing to SD cards. It can be used for various projects for purposes such as data storage, logging, and file management.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Specifications&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!List&lt;br /&gt;
!Explanation&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;Supported Cards&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|Micro SD card, Micro SDHC card (High-speed card support)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;Power Level Conversion&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Supports interface with 5V and 3.3V systems.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;Power Supply Range&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| 4.5V - 5.5V, with an integrated 3.3V regulator circuit&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;Communication Interface&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Standard SPI interface.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;Pin Configuration&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|GND, VCC, MISO, MOSI, SCK, CS&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;Positioning Hole&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|4 M2 screw positioning holes (diameter 2.2mm)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Application Examples&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
=== Circuit Configuration ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Arduino&lt;br /&gt;
!SD Card Module&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|CS&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|MOSI&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|MISO&lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|SCK&lt;br /&gt;
|-&lt;br /&gt;
|GND&lt;br /&gt;
|GND&lt;br /&gt;
|-&lt;br /&gt;
|5V or 3.3V&lt;br /&gt;
|VCC&lt;br /&gt;
|}&lt;br /&gt;
[[파일:SD카드모듈회로.jpg|가운데|class=coders100]]&lt;br /&gt;
&lt;br /&gt;
=== SD Card Format ===&lt;br /&gt;
In this example, we format the SD card to start with a clean state.&lt;br /&gt;
&lt;br /&gt;
Connect the SD card reader to your PC and right-click the folder to format it.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;lt;u&amp;gt;(※ This is not mandatory! Always back up important data on the SD card.)&amp;lt;/u&amp;gt;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[파일:SD카드포맷.png|class=coders30]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 1. Writing to the SD Card ===&lt;br /&gt;
This is an example of writing the phrase &amp;quot;GONGZIPSA&amp;quot; to the SD card. A text file will be created inside.&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;SD.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File myFile;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  &lt;br /&gt;
  // Initialize SD card&lt;br /&gt;
  if (!SD.begin(4)) {&lt;br /&gt;
    Serial.println(&amp;quot;SD card initialization failed&amp;quot;);&lt;br /&gt;
    return;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // File writing&lt;br /&gt;
  myFile = SD.open(&amp;quot;test.txt&amp;quot;, FILE_WRITE);&lt;br /&gt;
  &lt;br /&gt;
  if (myFile) {&lt;br /&gt;
    Serial.println(&amp;quot;test.txt File writing start&amp;quot;);&lt;br /&gt;
    myFile.println(&amp;quot;GONGZIPSA&amp;quot;);&lt;br /&gt;
    myFile.close();&lt;br /&gt;
    Serial.println(&amp;quot;File writing completed&amp;quot;);&lt;br /&gt;
  } else {&lt;br /&gt;
    Serial.println(&amp;quot;File writing failed&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to FILE_WRITE on line 15, there is also a READ mode.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Mode&lt;br /&gt;
!Explanation&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;FILE_READ&amp;lt;/code&amp;gt;&lt;br /&gt;
|The file is opened in read-only mode. It cannot be written to. If the file does not exist, it cannot be opened.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;FILE_WRITE&amp;lt;/code&amp;gt;&lt;br /&gt;
|The file is opened in write mode. If the file does not exist, it will be created. If an existing file is present, data will be appended to the end of the file. The existing content will not be overwritten.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Execution Result ====&lt;br /&gt;
[[파일:SD카드모듈예제1결과.jpg|가운데|class=coders100]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2. Reading Files from SD Card ===&lt;br /&gt;
&lt;br /&gt;
This is an example of reading files from the SD card and outputting them to the serial monitor.&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;SD.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File myFile;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  &lt;br /&gt;
  // Initialize SD card&lt;br /&gt;
  if (!SD.begin(4)) {&lt;br /&gt;
    Serial.println(&amp;quot;SD card initialization failed&amp;quot;);&lt;br /&gt;
    return;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // File Reading&lt;br /&gt;
  myFile = SD.open(&amp;quot;test.txt&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  if (myFile) {&lt;br /&gt;
    Serial.println(&amp;quot;test.txt File reading start&amp;quot;);&lt;br /&gt;
    while (myFile.available()) {&lt;br /&gt;
      Serial.write(myFile.read());&lt;br /&gt;
    }&lt;br /&gt;
    myFile.close();&lt;br /&gt;
    Serial.println(&amp;quot;File reading completed&amp;quot;);&lt;br /&gt;
  } else {&lt;br /&gt;
    Serial.println(&amp;quot;File reading failed&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Execution Result ====&lt;br /&gt;
[[파일:SD카드모듈예제2결과.png|가운데|class=coders100]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 3. Checking the List of Files on the SD Card ===&lt;br /&gt;
This is an example of outputting the list of files on the SD card to the serial monitor.&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;SD.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
&lt;br /&gt;
  // Initialize SD card  &lt;br /&gt;
  if (!SD.begin(4)) {&lt;br /&gt;
    Serial.println(&amp;quot;SD card initialization failed&amp;quot;);&lt;br /&gt;
    return;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  Serial.println(&amp;quot;File list:&amp;quot;);&lt;br /&gt;
  listFiles(SD.open(&amp;quot;/&amp;quot;));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void listFiles(File dir) {&lt;br /&gt;
  while (true) {&lt;br /&gt;
    File entry = dir.openNextFile();&lt;br /&gt;
    if (!entry) {&lt;br /&gt;
      break; // No more files left&lt;br /&gt;
    }&lt;br /&gt;
    Serial.print(entry.name());&lt;br /&gt;
    if (entry.isDirectory()) {&lt;br /&gt;
      Serial.println(&amp;quot; [directory]&amp;quot;);&lt;br /&gt;
      listFiles(entry); // Recursively output files within the directory&lt;br /&gt;
    } else {&lt;br /&gt;
      Serial.print(&amp;quot; [File size: &amp;quot;);&lt;br /&gt;
      Serial.print(entry.size());&lt;br /&gt;
      Serial.println(&amp;quot; bytes]&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    entry.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Execution Result ====&lt;br /&gt;
[[파일:SD카드모듈예제3결과.png|가운데|class=coders100]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 4. Logging Sensor Data ===&lt;br /&gt;
This is an example of recording data from the [[Soil Moisture Sensor(YL-69)]] every 3 seconds and saving it to the SD card.&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;SPI.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SD.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
&lt;br /&gt;
  // Initialize SD card&lt;br /&gt;
  if (!SD.begin(4)) {&lt;br /&gt;
    Serial.println(&amp;quot;SD card initialization failed&amp;quot;);&lt;br /&gt;
    return;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Initialize YL-69 Sensor (Set analogpin)&lt;br /&gt;
  pinMode(A0, INPUT);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  // Reading data from the YL-69 sensor&lt;br /&gt;
  int moistureLevel = analogRead(A0);&lt;br /&gt;
&lt;br /&gt;
  // Open the moisture.txt file in FILE_WRITE mode&lt;br /&gt;
  File myFile = SD.open(&amp;quot;moisture.txt&amp;quot;, FILE_WRITE);&lt;br /&gt;
  &lt;br /&gt;
  if (myFile) {&lt;br /&gt;
    // Write sensor data to the file&lt;br /&gt;
    myFile.print(&amp;quot;Moisture Level: &amp;quot;);&lt;br /&gt;
    myFile.println(moistureLevel); // Append data to the file&lt;br /&gt;
    myFile.close(); // Close the file&lt;br /&gt;
    Serial.println(&amp;quot;Data recording completed&amp;quot;);&lt;br /&gt;
  } else {&lt;br /&gt;
    Serial.println(&amp;quot;File write failed&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  delay(3000); // Record data every 3 seconds&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Execution Result ====&lt;br /&gt;
The serial monitor displays &amp;quot;Data recording completed,&amp;quot; and when you connect the SD card to the PC, you will find the previously created TEXT.txt file along with the newly recorded MOISTURE.txt file. You can confirm that the MOISTURE.txt file contains data from the soil moisture sensor (YL-69).&lt;br /&gt;
[[파일:SD카드모듈예제4결과.jpg|가운데|class=coders100]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Purchase Link&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
[https://gongzipsa.com/shop/1717136808 GONGZIPSA]&lt;/div&gt;</summary>
		<author><name>ArduWiki</name></author>
	</entry>
</feed>