At the begining, sorry for my bad english.
i made lcd 20x4 for showing row 1
Time, day, date
row 2 is Humi and Mooncalender
row 3 is Temperature and Day
row 4 is Dust Sensor all ofthing i can with
3 module Ds3231 DHT11 and GP2Y10 (dust sensor)
in row 4 is dust sensor have bad code and sensor or maybe i do something wrong to connect with my Arduino Mega
now i want row 1 with time delay(1000) each or ":" or "<3" appear in 0,5s and the sec time is 1s each
for all time like row 2 and 3
but the row 4 i named it PM2.5 : appear 5s each because something wrong with my sensor is dancing number
look very confusion
anyone can help me fix Row for with delay or Timer or millis plz, cause im just joint code and arduino for a week and don't know much about code for understand and more !!!
thx GUYS 3000!
my Code is here
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>; //sda ket noi sda ,scl knoi scl
#include <DS3231.h>
#include <SPI.h>
#include <DHT.h>
///////////////////////
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27,20,4);
DS3231 rtc(SDA, SCL); //chan 20 và 21 arduino mega
Time t;
void setup()
{
lcd.begin();
Serial.begin(9600);
rtc.begin();
dht.begin();
/////////set thoi gian xong xoas va nap lai code//////////////////////
//rtc.setDOW(2);
//rtc.setTime(19, 32, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(6, 4, 2020); // Set the date to January 1st, 2014
//Time();
////////////////////////////////////////////////////////
lcd.createChar(1, degree); // dat char 1 la degree
lcd.createChar(2, heart); // dat char 2 la heart
lcd.createChar(3, temp);
lcd.createChar(4, humi);
lcd.createChar(5, micro);
pinMode(ledPower, OUTPUT);
pinMode(dustPin, INPUT);
}
void loop()
{
thoi_gian();
nhay_s();
getTemperature();
am_lich(1);
thu();
dustSensor();
}
void nhay_s()
{
lcd.setCursor(2, 0);
lcd.print(":");
delay(250);
lcd.setCursor(2, 0);
lcd.write(2);
delay(250);
lcd.setCursor(5, 0);
lcd.print(":");
delay(250);
lcd.setCursor(5, 0);
lcd.write(2);
delay(250);
}
void thoi_gian()
{
t = rtc.getTime();
lcd.setCursor(2, 0);
lcd.print(":");
lcd.setCursor(5, 0);
lcd.print(":");
if(t.hour<10)
{
lcd.setCursor(0, 0);
lcd.print("0");
lcd.setCursor(1,0);
lcd.print(t.hour);
}
else{
lcd.setCursor(0, 0);
lcd.print(t.hour);
}
if(t.min<10)
{
lcd.setCursor(3, 0);
lcd.print("0");
lcd.setCursor(4,0);
lcd.print(t.min);
}
else{
lcd.setCursor(3, 0);
lcd.print(t.min);
}
if(t.sec<10)
{
lcd.setCursor(6, 0);
lcd.print("0");
lcd.setCursor(7,0);
lcd.print(t.sec);
}
else{
lcd.setCursor(6, 0);
lcd.print(t.sec);
}
void getTemperature()
{
lcd.setCursor(0, 1);
lcd.write(4);
lcd.print(": ");
lcd.print(round(hum));
lcd.print("%");
lcd.setCursor(0, 2);
lcd.write(3);
lcd.print(": ");
lcd.print(tem);
lcd.setCursor(7, 2);
lcd.print(char(223));
lcd.print("C");
lcd.print("/");
lcd.print(round(tem * 1.8 + 32));
lcd.print("\xDF");
lcd.print("F");
void dustSensor()
{
// Dust Sensor //
digitalWrite(ledPower, LOW); // power on the LED
delayMicroseconds(delayTime);
float dustVal = analogRead(dustPin);
delayMicroseconds(delayTime2);
digitalWrite(ledPower, HIGH); // turn the LED off
delayMicroseconds(offTime);
// calculate Dust density
// http://www.howmuchsnow.com/arduino/airquality/
// y (dust density mg/m3) = 0.172*x - 0.0999
float dustDensity = (0.172 *(dustVal *(5/1024.0))- 0.0999) *1000;
// LCD output
lcd.setCursor(0, 3);
lcd.print("PM2.5: ");
lcd.print(round(dustDensity));
lcd.setCursor(12, 3);
lcd.print("(");
lcd.write(5);
lcd.print("g/m3)");
}
.