简体   繁体   中英

How to Save and display data SD card on LCD

I am developing system using Arduino Nano that will detect water turbidity by using photodiode sensor and LED. Now, I trying to used SD card module to save data sensor.

I tried to used this code below in void loop (), and It works, the file was create test.txt and including data value sensor on Mymicro SD:

count_save++;    
if(count_save > 30){
count_save=0;
myFile=SD.open("Test.txt", FILE_WRITE);
if(myFile){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("save data");
myFile.print("Writing data sensor :");
myFile.print(" ");
myFile.print("turbidity=");
myFile.print(foto);
myFile.close();
delay(1000);
}else{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("error save");
delay(1000);
lcd.clear();
}
}
} 

But in Myplan, I want to SD card save data when I am press button1 at once, and when I press button2 it will display the data sensor on LCD.

please, help how to solved this problem...

Instead of just looping, you should branch (use if) to check if a button has pressed

IOs have to be configured as inputs, don't forget pull-up/downs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM