完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include
LiquidCrystal lcd(3, 2, 7, 6, 5, 4); #define SensorPin 0 //pH meter Analog output to Arduino Analog Input 0 #define Offset 0.00 //deviation compensate unsigned long int avgValue; //Store the average value of the sensor feedback int S1; int S2; int S3; int S4; int S5; int S6; void setup() { pinMode(8, INPUT); pinMode(9, INPUT); pinMode(10, INPUT); pinMode(11, INPUT); pinMode(12, INPUT); pinMode(13, INPUT); Serial.begin(9600); Serial.prinOUTPUTtln("Ready"); //Test the serial monitor } void loop() { int buf[10]; //buffer for read analog for (int i = 0; i < 10; i++) //Get 10 sample value from the sensor for smooth the value { buf = analogRead(SensorPin); delay(10); } for (int i = 0; i < 9; i++) //sort the analog from small to large { for (int j = i + 1; j < 10; j++) { if (buf > buf[j]) { int temp = buf; buf = buf[j]; buf[j] = temp; } } } avgValue = 0; for (int i = 2; i < 8; i++) //take the average value of 6 center sample avgValue += buf; float phValue = (float)avgValue * 5.0 / 1024 / 6; //convert the analog into millivolt phValue = 3.5 * phValue + Offset; //convert the millivolt into pH value Serial.print(" pH:"); Serial.print(phValue, 2); Serial.println(" "); digitalWrite(13, HIGH); delay(800); digitalWrite(13, LOW); lcd.setCursor(0, 1); lcd.print("PH:"); lcd.print(phValue, 2); if(digitalRead(9) == LOW) { lcd.setCursor(10, 1); lcd.print("text"); } else { lcd.setCursor(10, 1); lcd.print("meian"); } } 一共6个按键,我该如何用 state将测得的值实现按按键1,进入text(校准界面)并且对当前数据调整 按键23对当前光标位变大变小。 按键45让光标左右移并且使按键23可以调整其他位置大小。6确定(退出调整) |
|
相关推荐
1个回答
|
|
疯狂打call
|
|
|
|
只有小组成员才能发言,加入小组>>
9858 浏览 19 评论
10269 浏览 0 评论
3936 浏览 0 评论
8868 浏览 8 评论
2485 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 09:33 , Processed in 0.820315 second(s), Total 79, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号