- #include <SD.h>//SD卡模块
- #include <SPI.h>
- #define PIN_AO 0//湿度传输口0
- #define PIN_AO 1//湿度传输口1
- #define PIN_AO 2//湿度传输口1
- #define PIN_AO 3//湿度传输口1
- #define PIN_AO 4//湿度传输口1
- File myFile;
- int pinCS = 4;
- void setup()
- {
- Serial.begin(9600);//链接电脑输出
- pinMode(pinCS,OUTPUT);
- pinMode(PIN_AO, INPUT);
- pinMode(PIN_A1, INPUT);
-
- if (SD.begin())
- {Serial.println("SD card is ready to use");
- }else
- {Serial.println("SD card aaaazinutialization failed");
- return;
- }
- myFile=SD.open("test.txt",FILE_WRITE);//创建并打开文件进行写入
- //SD.remove("example.txt"); //删除文件example.txt
- }
- void loop()
- {
- myFile=SD.open("test.txt",FILE_WRITE);//创建并打开文件进行写入
- Serial.print("AO=");
- Serial.println(analogRead(PIN_AO));
- Serial.print("A1=");
- Serial.println(analogRead(PIN_A1));
- Serial.print("A2=");
- Serial.println(analogRead(PIN_A2));
- Serial.print("A3=");
- Serial.println(analogRead(PIN_A3));
- Serial.print("A4=");
- Serial.println(analogRead(PIN_A4));
-
- myFile.print("AO=");
- myFile.println(analogRead(PIN_AO));
- myFile.print("A1=");
- myFile.println(analogRead(PIN_A1));
- myFile.print("A2=");
- myFile.println(analogRead(PIN_A2));
- myFile.print("A3=");
- myFile.println(analogRead(PIN_A3));
- myFile.print("A4=");
- myFile.println(analogRead(PIN_A4));
-
-
- myFile.close();
- delay(1000);
- }
复制代码
|