Arduino UNO驱动micro SD卡读写模块
目录
- 一、简介
- 二、使用前准备
- 三、测试方法
- 四、实验现象
一、简介
Micro SD卡模块TF卡读写卡器板载电平转换电路,即接口电平可为5V或3.3V,支持支持Micro SD卡(≤2G)、Micro SDHC高速卡(≤32G)。供电电源为4.5V~5.5V,板载3.3V稳压电路,为电平转换芯片、Micro SD卡供电。通信接口为标准SPI接口,通过文件系统及SPI接口驱动程序,单片机系统即可完成MicroSD卡内的文件进行读写。带有4个M2螺丝定位孔,便于安装。
控制接口:共6个引脚(GND、VCC、MISO、MOSI、SCK、CS),GND为地,VCC为供电电源,MISO、MOSI、SCK为SPI总线,CS为片选信号脚;
二、使用前准备
点击图片购买 Micro SD卡模块TF卡读写卡器
点击图片购买 原装正版Arduino uno r3开发板
点击图片购买 USB2.0打印机数据线高速方口连接转接线 A公对B公
点击图片购买 杜邦线
Micro SD卡模块TF卡读写卡器 | 1个 |
---|---|
原装正版Arduino uno r3开发板 | 1个 |
USB2.0打印机数据线高速方口连接转接线 A公对B公 | 1条 |
杜邦线 | 若干 |
三、测试方法
用USB2.0打印机数据线高速方口连接转接线与Arduino uno r3开发板连接在一起。Arduino uno r3开发板和Micro SD卡模块连接,插入一张Micro SD卡,如下图所示
Arduino UNO | SD卡模块 |
---|---|
5V | VCC |
GND | GND |
4 | MOSI |
11 | MOSI |
12 | MISO |
13 | SCK |
打开ArduinoIDE,先点击【文件】,再点击【SD】,最后点击【CardInfo】,如下图所示
代码如下:
/*SD card testThis example shows how use the utility libraries on which the'SD library is based in order to get info about your SD card.Very useful for testing a card when you're not sure whether its working or not.The circuit:SD card attached to SPI bus as follows:** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila** CS - depends on your SD card shield or module.Pin 4 used here for consistency with other Arduino examplescreated 28 Mar 2011by Limor Friedmodified 9 Apr 2012by Tom Igoe
*/
// include the SD library:
#include <SPI.h>
#include <SD.h>// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
// MKRZero SD: SDCARD_SS_PIN
const int chipSelect = 4;void setup() {// Open serial communications and wait for port to open:Serial.begin(9600);while (!Serial) {; // wait for serial port to connect. Needed for native USB port only}Serial.print("\nInitializing SD card...");// we'll use the initialization code from the utility libraries// since we're just testing if the card is working!if (!card.init(SPI_HALF_SPEED, chipSelect)) {Serial.println("initialization failed. Things to check:");Serial.println("* is a card inserted?");Serial.println("* is your wiring correct?");Serial.println("* did you change the chipSelect pin to match your shield or module?");while (1);} else {Serial.println("Wiring is correct and a card is present.");}// print the type of cardSerial.println();Serial.print("Card type: ");switch (card.type()) {case SD_CARD_TYPE_SD1:Serial.println("SD1");break;case SD_CARD_TYPE_SD2:Serial.println("SD2");break;case SD_CARD_TYPE_SDHC:Serial.println("SDHC");break;default:Serial.println("Unknown");}// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32if (!volume.init(card)) {Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");while (1);}Serial.print("Clusters: ");Serial.println(volume.clusterCount());Serial.print("Blocks x Cluster: ");Serial.println(volume.blocksPerCluster());Serial.print("Total Blocks: ");Serial.println(volume.blocksPerCluster() * volume.clusterCount());Serial.println();// print the type and size of the first FAT-type volumeuint32_t volumesize;Serial.print("Volume type is: FAT");Serial.println(volume.fatType(), DEC);volumesize = volume.blocksPerCluster(); // clusters are collections of blocksvolumesize *= volume.clusterCount(); // we'll have a lot of clustersvolumesize /= 2; // SD card blocks are always 512 bytes (2 blocks are 1KB)Serial.print("Volume size (Kb): ");Serial.println(volumesize);Serial.print("Volume size (Mb): ");volumesize /= 1024;Serial.println(volumesize);Serial.print("Volume size (Gb): ");Serial.println((float)volumesize / 1024.0);Serial.println("\nFiles found on the card (name, date and size in bytes): ");root.openRoot(volume);// list all files in the card with date and sizeroot.ls(LS_R | LS_DATE | LS_SIZE);
}void loop(void) {}
四、实验现象
打开串口助手,可获得卡的一些基本信息
Arduino UNO驱动micro SD卡读写模块相关推荐
- Arduino ESP8266 Micro SD卡读写操作实例
Arduino ESP8266 Micro SD卡读写操作实例 相关篇<Arduino ESP8266 Micro SD卡读写操作实例> 接线说明 Micro SD ---- ESP826 ...
- Arduino ESP32 读取Micro sd卡容量信息示例
Arduino ESP32 读取Micro sd卡容量信息示例 接线说明 ESP32 ----Micro SD VIN (DEVKIT这个引脚有5V电压)---- VCC GND ----GND D2 ...
- nRF52832学习记录(十二、SPI接口的应用 Micro SD卡读写测试)
目录 1.nRF52xx SPI介绍 SPI接口基础介绍 SPI 寄存器 SPI 库函数介绍 SPI初始化函数 SPI数据传输函数 2.nRF52xx SPI 使用示例 w25qxx SPI Flas ...
- 【雕爷学编程】Arduino动手做(52)---MicroSD卡读写模块
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践(动手试试)出真知的理念,以学习和交流为目的,这里准备 ...
- STM32-M3(野火)SD卡读写/移植znFAT文件访问系统
设备: STM32F103VE-M3,板载SD卡读写模块. 源码: 野火的SD卡扇区读写驱动,振南FAT的STM32版本. 另有1G-16G SD卡若干张. 移植过程: SD卡扇区读写驱动测试,SD卡 ...
- nios ii之Micro SD卡(TF卡)spi
上一篇文章已经介绍了Micro SD卡SPI模式的实现方法,这里给出自己写的基于nios ii的Micro SD卡读写程序(IO口模拟spi). 硬件设计就不多说了,主要是添加4的1为PIO口来模拟S ...
- Micro SD卡(TF卡)spi
转自:http://blog.csdn.net/ming1006/article/details/7283689 上一篇文章已经介绍了Micro SD卡SPI模式的实现方法,这里给出自己写的基于nio ...
- Arduino ESP32 SD卡读写实例
Arduino ESP32 SD卡读写实例 Arduino官方文档参考:https://www.arduino.cc/en/Reference/SD SD卡硬件连接方式 ESP32有两种使用SD卡的方 ...
- Arduino UNO驱动 AT24C256 EEPROM存储器模块
Arduino UNO驱动 AT24C256 EEPROM存储器模块 AT24C256模块简介 模块引脚定义 Arduino UNO与模块接线 测试代码 实验结果 AT24C256模块简介 AT24C ...
最新文章
- linux之LAMP架构优化
- iOS集成OpenCV遇到的问题
- wpf中把按钮变成圆角
- 工业相机与民用相机的区别_工业相机和普通相机的区别详解
- 微软 Azure 再下一城:收购 Kinvolk,改进开源 Linux
- Sysbench 性能压测-MySQL
- 【前端基础】Web与Native交互之The JSBridge FAQ
- linux mysql cpu 查看工具_Linux监控工具-Nmon命令行:Linux系统性能的监测利器
- 【渝粤教育】国家开放大学2018年春季 7392-21TMatlab语言及其应用 参考试题
- 用ASP.NET刷新页面的几种有效方法
- 浅谈Kotlin(四):控制流
- java-php-python-ssm在线购书商城系统计算机毕业设计
- mx350显卡天梯图_分享电脑显卡天梯图2020
- android expandablelistview简单应用,android ExpandableListView简单例子
- Win10环境下安装VS2010旗舰版 和安装Visual Assist10.9.2108.0
- 金字塔原理4个基本原则_如何处理人际关系?复杂不如简单,了解6个基本原则,豁然开朗...
- 西湖论剑2020writeup
- 使用超级表格快速创建在线表单(如问卷调查、报名表)
- 一个高中生的编程自学经历
- mq中消息消费的几种方式