关于CS引脚,如果是arduino ethernet或一般micro SD模块,程序默认D4,但要注意adafruit和SParkfun这两家的SD模块,需要变换,如下
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
注意,ethernet扩展板的pin4默认输出,即使不用这个脚,10脚(mega pin53)都要设置为输出,否则SD库无法使用,说明如下
// 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.
程序中确实有这句,虽然我们没有用D10
pinMode(10, OUTPUT);
SD卡类型有SD1、SD2、SDHC,大多数SD模块支持的SD类型容量是2G以下,SDHC的容量是32G以下,