Arduino LCD 温度显示

小学期第二天实验内容:用LCD显示屏显示当前温度,一秒钟刷新两次实验器材:跳线、LCD显示屏、温度传感器、可调电阻、面包板、数据线、220欧姆电阻电路图:代码: // include the library code: #include  // initialize the library with the numbers of the interf
摘要由CSDN通过智能技术生成

小学期第二天

实验内容:用LCD显示屏显示当前温度,一秒钟刷新两次

实验器材:跳线、LCD显示屏、温度传感器、可调电阻、面包板、数据线、220欧姆电阻

电路图:


代码:

 // include the library code:
 #include <LiquidCrystal.h>

 // initialize the library with the numbers of the interface pins
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 void setup() {
   // set up the LCD's number of columns and rows:
   lcd.begin(16, 2);
   // Print a message to the LCD.
   lcd.print("The temperature");
   lcd.setCursor(0, 1);
   lcd.print("is: ");
   Serial.begin(9600); 
 }

 void loop() {
   float dat;
   int n = analogRead(A0);    //读取A0口的电压值
   dat = n*(5.0/1023.0*100);   //使用浮点数存储温度数据ÿ
  • 3
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值