Basic weather
system, in/out temp and humidity with the heat index, dew point, pressure and weather
prediction and time and date.
Story
I have an outside shed where I wanted a
clock, so I made a simple clock with date on a 20x4 LCD. I then decided it
looked a bit boring so I added inside temperature and humidity. Updated it
again to show outside temp and humidity. Then just kept adding things like
pressure and predictions.
My sketch shows a 20x4 LCD that rotates
through the screens to show date and time, inside and outside temperature,
pressure, and weather prediction (like a barometer). As an extra, I added the
outside heat index and dew point as well using the DHT22 for the readings. I
also added a 4 digit display to constantly show the time as this was the main
idea for the project.
The BMP280, LCD, and Ds3231 (ZS-042) are
connected by I2C.
Remember the BMP280 uses 3.3v and not 5v
I used a DHT22 for outside temp and
humidity and a DHT11 for inside temp and humidity. It was what I had in my
spares box but any sensor could be used (with a little tweak to the code). The
DHT11 is less accurate, showing only whole numbers but is good enough for indications of my shed temp.
Just added sunrise, sunset and moon
information with a lunar phase-indictor.
Code:
#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DS1307RTC.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <DHT.h>
#include <Time.h>
#include <TimeLib.h>
#include <TM1637.h>
#include <sunMoon.h>
#define DHT1PIN 12 // DHT11 TO PIN 7
#define DHT2PIN 13 // DHT22 to PIN 13
#define DHT2TYPE DHT22 // DHT22
#define DHT1TYPE DHT11 // DHT11
#define CLK 11 // 7 segment display PIN CLK
#define DIO 10 // 7 segment display PIN DIO
#define OUR_latitude 50.770854 // Sidlesham cordinates
#define OUR_longtitude -0.784057
#define OUR_timezone 0 // localtime with UTC difference in minutes
float V = 6.2; //version
sunMoon sm;
TM1637 Display1(CLK, DIO);
int8_t Digits[] = {0, 1, 2, 3};
int hours;
int minutes;
const int led1 = 2; //New Moon (Blue LED)
const int led2 = 3; //Waxing Cresent (White LED)
const int led3 = 4; //First Quarter (White LED)
const int led4 = 5; //Waxing Gibbon (White LED)
const int led5 = 6; //Full Moon (White LED)
const int led6 = 7; //Wanning Gibbon (White LED)
const int led7 = 8; //Last Quarter (White LED)
const int led8 = 9; //Waning Cresent (White LED)
byte mDay = sm.moonDay();
boolean alterna;
DHT dht2 (DHT2PIN, DHT2TYPE); //outside temp,hum
DHT dht1 (DHT1PIN, DHT1TYPE); //inside temp,hum
Adafruit_BMP280 bme;
LiquidCrystal_I2C lcd(0x27, 20, 4); // Set the LCD I2C address
int chk;
float temp1; //Inside Temperature
float hum1; //Inside Humidity
float temp2; //Outside Temperature
float hum2; //Outside Humidity
float Pressure; //Pressure!
float dp; //Dew Point Outside
float temp2f; //temp outside in F
float hif; //Heat index in F
float hic; //Heat Index in C
float sRise; //Sun Rise Calculation
float sSet; //Sun Set Calculation
unsigned long switchMillis = 0;
unsigned long interval = 5000; // 5 seconds for each lcd screen
byte count = 0;
boolean firstScreenFlag = false;
boolean secondScreenFlag = false;
boolean thirdScreenFlag = false;
boolean fouthScreenFlag = false;
boolean fifthScreenFlag = false;
void setup()
{
tmElements_t tm; // specific time
time_t s_date = makeTime(tm);
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
time_t sRise = sm.sunRise();
time_t sSet = sm.sunSet();
sRise = sm.sunRise(s_date);
sSet = sm.sunSet(s_date);
Serial.begin(9600);
Display1.set();
Display1.init();
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
lcd.init();
lcd.clear();
lcd.backlight();
dht1.begin();
dht2.begin();
Wire.begin();
lcd.setCursor(0, 0);
lcd.print(F(" Weather Station"));
lcd.setCursor(3, 2);
lcd.print(F("Version : "));
lcd.print(V, 1);
delay(3000);
lcd.clear();
if (!bme.begin())
{
while (1);
}
}
void loop()
{
tmElements_t tm;
time_t s_date = makeTime(tm);
if (RTC.read(tm)) {
print2digits(tm.Hour);
print2digits(tm.Minute);
hours = tm.Hour;
minutes = tm.Minute;
CalculaDigits(hours, minutes);
if (alterna)
{
Display1.point(POINT_OFF);
alterna = false;
}
else
{
Display1.point(POINT_ON);
alterna = true;
}
} else {
if (RTC.chipPresent()) {
} else {
}
delay(9000);
}
delay(1000);
if (millis() - switchMillis > interval)
{
count++;
if (count == 1)
{
firstScreenFlag = true;
count = 1;
}
if (count == 2)
{
secondScreenFlag = true;
count = 2;
}
if (count == 3)
{
thirdScreenFlag = true;
count = 3;
}
if (count == 4)
{
fouthScreenFlag = true;
count = 4;
}
if (count == 5)
{
fifthScreenFlag = true;
count = 0;
}
switchMillis += interval;
}
if (firstScreenFlag)
{
printTime(1, 0, tm);
firstScreenFlag = false;
}
if (secondScreenFlag)
{
printTemp();
secondScreenFlag = false;
}
if (thirdScreenFlag)
{
printIndex();
thirdScreenFlag = false;
}
if (fouthScreenFlag)
{
printPressure();
fouthScreenFlag = false;
}
if (fifthScreenFlag)
{
printMoon(tm);
fifthScreenFlag = false;
}
}
void printLcdDate(time_t date)
{
char rise[10];
sprintf(rise, "%02d:%02d", hour(date), minute(date));
lcd.print(rise);
}
void printTime(int character, int line, tmElements_t tm)
{
lcd.clear();
String seconds, minutes;
lcd.setCursor(character, line);
lcd.print(tm.Hour);
lcd.print(F(":"));
if (tm.Minute < 10)
{
minutes = "0" + String(tm.Minute);
lcd.print(minutes);
} else
{
lcd.print(tm.Minute);
}
lcd.setCursor(9, 0);
lcd.print(tm.Day);
lcd.print(F("/"));
lcd.print(tm.Month);
lcd.print(F("/"));
lcd.print(tmYearToCalendar(tm.Year));
time_t s_date = makeTime(tm);
time_t sRise = sm.sunRise();
time_t sSet = sm.sunSet();
sRise = sm.sunRise(s_date);
sSet = sm.sunSet(s_date);
lcd.setCursor(1, 2);
lcd.print(F("SunRise : "));
printLcdDate(sRise);
lcd.setCursor(1, 3);
lcd.print(F("SunSet : "));
printLcdDate(sSet);
}
void printTemp()
{
hum1 = dht1.readHumidity(); //inside
temp1 = dht1.readTemperature(); //inside
hum2 = dht2.readHumidity(); //outside
temp2 = dht2.readTemperature(); //outside
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F(" Inside Outside"));
lcd.setCursor(0, 2);
lcd.print(F("T: "));
lcd.print(temp1, 1);
lcd.print(F(" "));
lcd.print((char)223);
lcd.print(F("C"));
lcd.setCursor(13, 2);
lcd.print(temp2, 1);
lcd.print(F(" "));
lcd.print(( char)223);
lcd.print(F("C"));
lcd.setCursor(0, 3);
lcd.print(F("H: "));
lcd.print(hum1, 0);
lcd.print(F(" %"));
lcd.setCursor(14, 3);
lcd.print(hum2, 0);
lcd.print(F(" %"));
}
void printIndex()
{
hum2 = dht2.readHumidity(); //outside
temp2 = dht2.readTemperature(); //outside
temp2f = dht2.readTemperature(true); // temp in f
double Point = log(hum2 / 100) + ((17.62 * temp2) / (243.5 + temp2));
double dp = 243.5 * Point / (17.62 - Point);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F(" Outside Readings"));
lcd.setCursor(0, 2);
lcd.print(F("Dew Point : "));
lcd.print(dp, 1);
lcd.print(F(" "));
lcd.print((char)223);
lcd.print(F("C"));
hif = dht2.computeHeatIndex(temp2f, hum2); //heat index in degrees F
hic = dht2.computeHeatIndex(temp2, hum2, false); //heat index in degrees C
lcd.setCursor(0, 3);
lcd.print(F("Heat Index : "));
lcd.print(hic, 1);
lcd.print(F(" "));
lcd.print((char)223);
lcd.print(F("C"));
}
void printPressure()
{
Pressure = (bme.readPressure() / 100); // 100 Pa = 1 millibar
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(F(" Press : "));
lcd.print(Pressure);
lcd.print(F(" mb"));
lcd.setCursor(0, 3);
lcd.print(F("Weather :"));
if (Pressure <= 970); {
lcd.setCursor(13, 3);
lcd.print(F(" "));
lcd.setCursor(13, 3);
lcd.print(F("Stormy"));
}
if (Pressure > 970) {
lcd.setCursor(11, 3);
lcd.print(F(" "));
lcd.setCursor(11, 3);
lcd.print(F("Much Rain"));
}
if (Pressure > 996) {
lcd.setCursor(11, 3);
lcd.print(F(" "));
lcd.setCursor(13, 3);
lcd.print(F("Rain"));
}
if (Pressure > 1006) {
lcd.setCursor(11, 3);
lcd.print(F(" "));
lcd.setCursor(11, 3);
lcd.print(F("Variable"));
}
if (Pressure > 1030) {
lcd.setCursor(11, 3);
lcd.print(F(" "));
lcd.setCursor(13, 3);
lcd.print(F("Fair"));
}
if (Pressure > 1040) {
lcd.setCursor(11, 3);
lcd.print(F(" "));
lcd.setCursor(11, 3);
lcd.print(F("Set Fair"));
}
if (Pressure > 1060) {
lcd.setCursor(11, 3);
lcd.print(F(" "));
lcd.setCursor(11, 3);
lcd.print(F("Very Dry"));
}
}
void printMoon(tmElements_t tm)
{
time_t s_date = makeTime(tm);
mDay = sm.moonDay(s_date);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Moon age is ");
lcd.print(mDay);
if (mDay == 1) {
lcd.print(" day ");
}
else {
lcd.print(" days");
}
lcd.setCursor(0, 2);
if (mDay == 0) {
lcd.setCursor(0, 2);
lcd.print(" New Moon ");
lcd.setCursor(0, 3);
lcd.print(" Illumination 0 % ");
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 1) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 1 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 2) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 4 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 3) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 8 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 4) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 15 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 5) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 22 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 6) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 31 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 7) {
lcd.setCursor(0, 2);
lcd.print(" First Quarter ");
lcd.setCursor(0, 3);
lcd.print(" Illumination 50 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 8) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 58 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 9) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 68 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 10) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 76 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 11) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 84 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 12) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 91 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 13) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 96 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 14) {
lcd.setCursor(0, 2);
lcd.print(" Waxing Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 99 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 15) {
lcd.setCursor(0, 2);
lcd.print(" Full Moon ");
lcd.setCursor(0, 3);
lcd.print(" Illumination 100 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, HIGH);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 16) {
lcd.setCursor(0, 2);
lcd.print(" Waning Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 98 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 17) {
lcd.setCursor(0, 2);
lcd.print(" Waning Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 93 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 18) {
lcd.setCursor(0, 2);
lcd.print(" Waning Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 86 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 19) {
lcd.setCursor(0, 2);
lcd.print(" Waning Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 77 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 20) {
lcd.setCursor(0, 2);
lcd.print(" Waning Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 67 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 21) {
lcd.setCursor(0, 2);
lcd.print(" Waning Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 56 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 22) {
lcd.setCursor(0, 2);
lcd.print(" Waning Gibbons");
lcd.setCursor(0, 3);
lcd.print(" Illumination 52 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
if (mDay == 23) {
lcd.setCursor(0, 2);
lcd.print(" Last Quarter ");
lcd.setCursor(0, 3);
lcd.print(" Illumination 50 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, HIGH);
digitalWrite(led8, LOW);
}
if (mDay == 24) {
lcd.setCursor(0, 2);
lcd.print(" Waning Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 34 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, HIGH);
}
if (mDay == 25) {
lcd.setCursor(0, 2);
lcd.print(" Waning Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 24 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, HIGH);
}
if (mDay == 26) {
lcd.setCursor(0, 2);
lcd.print(" Waning Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 15 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, HIGH);
}
if (mDay == 27) {
lcd.setCursor(0, 2);
lcd.print(" Waning Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 8 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, HIGH);
}
if (mDay == 28) {
lcd.setCursor(0, 2);
lcd.print(" Waning Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 3 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, HIGH);
}
if (mDay == 29) {
lcd.setCursor(0, 2);
lcd.print(" Waning Cresent");
lcd.setCursor(0, 3);
lcd.print(" Illumination 1 % ");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, HIGH);
}
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}
void CalculaDigits( int hour, int min)
{
int8_t Digit0 = min % 10 ;
int8_t Digit1 = (min % 100) / 10 ;
int8_t Digit2 = hour % 10 ;
int8_t Digit3 = (hour % 100) / 10 ;
Digits[3] = Digit0 ;
Digits[2] = Digit1 ;
Digits[1] = Digit2 ;
Digits[0] = Digit3 ;
Display1.display(Digits);
}
Nice post admin!
ReplyDeleteUbiBot WS1 & WS1 Pro has advanced IoT sensor made with industrial-grade components and can measure temperature & humidity. these device allows you to monitor your environment in real-time remotely and gives you remote access to your data wherever you are in the world. To know more about these products feel free to visit UbiBot Online Store.