標題:
有關Arduino lcd1602顯示實時數(shù)據的問題
[打印本頁]
作者:
mioyo
時間:
2018-5-18 20:53
標題:
有關Arduino lcd1602顯示實時數(shù)據的問題
我想使用HX711采集壓力數(shù)據,并且實時顯示在lcd1602顯示屏上,但是實驗的結果是顯示屏毫無反應。。。麻煩各位大神看下我的程序,是不是程序出錯了啊
const int led=9;
const int button=13;
bool currentbutton=LOW;
bool lastbutton=LOW;
bool buttonstate=false;
#include<LiquidCrystal.h>
#include <HX711.h>
LiquidCrystal lcd(12,11,5,4,3,2);
HX711 hx(7, 8, 128, -0.00011890216);
void setup()
{
pinMode(led,OUTPUT);
pinMode(button,INPUT);
lcd.begin(16,2);
Serial.begin(9600);
}
bool xiaodou(bool last)
{
bool current=digitalRead(button);
if(current!=last)
{
delay(5);
current=digitalRead(button);
}
return current;
}
void loop()
{
currentbutton=xiaodou(lastbutton);
if(lastbutton==LOW&¤tbutton==HIGH)
{
buttonstate=!buttonstate;
}
lastbutton = currentbutton;
digitalWrite(led,buttonstate);
double sum1 = 0;
if(digitalRead(led) == HIGH)
{
for (int i = 0; i < 10; i++)
{
sum1 += hx.bias_read();
}
Serial.print("Force:");
Serial.print(sum1/10);
Serial.println("Kg");
if(Serial.available())
{
delay(1000);
lcd.clear();
while(Serial.available()>0)
{
lcd.write(Serial.read());
}
}
}
}
復制代碼
作者:
devcang
時間:
2018-5-19 10:01
沒有這樣的實物,測試不了的。。。。。。不是有串口嗎,連接串口去逐行 調試調試
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1