当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Project 024 - LCD Temperature Display

RonWang7个月前 (11-11)电子编程309

This project is a simple demonstration of using an LCD to present useful information to the user—in this case, the temperature from an DTH11 humidity and temperature sensor. 

Project 24 Liquid Crystal Temperature Displays 

Ardunio DHT11 Temperature Humidity Display Schematic

Ardunio DHT11 Temperature Humidity Display Circuit

/* Coding Ron Wang
   Nov.11th 2024
   Autaba support for coding hardware
   Project 24  LCD Temperature Display
 */
// Adding LCD and DHT libraries

#include <LiquidCrystal.h>
#include  <SimpleDHT.h>

//Declaring digital pin no 6 as the dht11 data pin

int  pinDHT11 = 11;
SimpleDHT11 dht11;

//Declaring the lcd pins

const  int rs = 9, en = 8, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en,  d4, d5, d6, d7);
void setup() {

 Serial.begin(9600); // Choose 9600 at the  port screen
 lcd.begin(16, 2);  //Telling our LCD to start up
     
}
void loop() {
  /*These  serial codes are for getting readings on the port screen as well as 
    the LCD display, since they'll offer us a more detailed interface
  */
  
  Serial.println("=================================");
  Serial.println("DHT11 readings...");
  
 
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  
  //This bit will tell our Arduino what to do if there is some sort of an error at getting readings  from our sensor
  
  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL))  != SimpleDHTErrSuccess) {
    Serial.print("No reading , err="); Serial.println(err);delay(1000);
    return;
  }
  
  Serial.print("Readings: ");
  Serial.print((int)temperature);  Serial.print(" Celcius, ");
  Serial.print((int)humidity); Serial.println("  %");
 
  //Telling our lcd to refresh itself every 0.75 seconds
  lcd.clear();
  
  //Choosing the first line and row
  lcd.setCursor(0,0);
  //Typing Temp:  to the first line starting from the first row
  lcd.print("Temp: ");
  //Typing  the temperature readings after "Temp: " 
  lcd.print((int)temperature);
  //Choosing the second line and first row
  lcd.setCursor(0,1);
  //Typing  Humidity(%): to the second line starting from the first row
  lcd.print("Humidity(%):  ");
  //Typing the humidity readings after "Humidity(%): "
  lcd.print((int)humidity);
 
  delay(750);
}

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://www.donstudio.cn/?id=278

标签: Arduino

相关文章

Arduino Project 011 - Piezo Sounder Alarm

Arduino Project 011 - Piezo Sounder Alarm

Arduino project - sounder and sensors : Include project 11 Piezo Sounder Alarm ,Project piezo sounde...

C语言调试运行环境TurboC的安装

C语言调试运行环境TurboC的安装

上大学时学习《C语言程序设计》(第二版)作者谭浩强,大部分编程时间是在学校机房度过,每次点开桌面的TurboC图标,就开始在里面敲代码,然后保存程序Abc.C,下一步进行编译,如果编译成功的话,就可以...

Arduino Project 030B - MX1508 H-Driver Motor

Arduino Project 030B - MX1508 H-Driver Motor

MX1508 H-BridgeDual Motor DriverThe driver can drive up to two motors. The H-Bridge dual motor drive...

Arduino Project 021 -  LED Dot Matrix Display - Scrolling Message

Arduino Project 021 - LED Dot Matrix Display - Scrolling Message

There are many different ways to drive LEDs. Using shift registers is one way and they have their a...

Arduino Project 018 - Dual Shift Register 8-Bit Binary Counter

Arduino Project 018 - Dual Shift Register 8-Bit Binary Counter

In Project 18, you will daisy chain (or cascade) another 74HC595 IC onto the one used in Project 17...

 Arduino Project 038 - Simple Ultrasonic Range HC-SR04

Arduino Project 038 - Simple Ultrasonic Range HC-SR04

Ultrasonic range finders measure distance by emitting a pulse of ultrasonic sound that travels throu...