简体   繁体   English

如何在LCD上保存和显示数据SD卡

[英]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. 我正在开发使用Arduino Nano的系统,该系统将通过使用光电二极管传感器和LED来检测水的浊度。 Now, I trying to used SD card module to save data sensor. 现在,我尝试使用SD卡模块保存数据传感器。

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: 我试图在下面的void loop()中使用此代码,并且可以正常工作,该文件创建为test.txt,并包含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. 但是在Myplan中,我想立即按一下button1来SD卡保存数据,而当我按下button2时,它将在LCD上显示数据传感器。

please, help how to solved this problem... 请帮忙解决这个问题...

Instead of just looping, you should branch (use if) to check if a button has pressed 您应该分支(使用if)来检查按钮是否被按下,而不是仅仅循环

IOs have to be configured as inputs, don't forget pull-up/downs. IO必须配置为输入,不要忘记上拉/下拉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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