The SD-CARD-READER-2PINS is a simplified SD card reader module designed for easy integration into electronic projects. It allows for the reading and writing of data to a standard SD card using only two pins for communication. This component is ideal for applications where data logging, storage, or transfer is required, such as in embedded systems, data recorders, or IoT devices.
Pin Name | Description |
---|---|
VCC | Power supply (3.3V to 5V) |
GND | Ground connection |
DIO | Data Input/Output |
CLK | Clock signal |
#include <SPI.h>
#include <SD.h>
// Define the SPI pins for Arduino UNO
const int chipSelectPin = 10; // Chip select pin for SD card reader
const int cardDetectPin = 2; // Card detect pin (optional)
void setup() {
Serial.begin(9600);
pinMode(chipSelectPin, OUTPUT);
// Check for the presence of the SD card
if (!SD.begin(chipSelectPin)) {
Serial.println("Card failed, or not present");
// Don't do anything more if the SD card is not present
while (1);
}
Serial.println("Card initialized.");
}
void loop() {
// Code to read or write data to the SD card
}
Note: The above code assumes that the SD-CARD-READER-2PINS uses the SPI interface with a chip select pin. Since the actual component has only two pins, the implementation may vary, and the code provided here is for illustrative purposes.
FAQs: