#include "segmentos.h"
#include <dht.h>
#include <RTClib.h>
int segs[] = { 2, 3, 4, 5 };
uint8_t digits[] = { 6, 7, 8, 9, 10, 11, 12};
Segments seg1(digits);
dht DHT;
RTC_DS1307 rtc;
void setup() {
Serial.begin(115200);
seg1.init();
for (int i : segs){
pinMode(i, OUTPUT);
digitalWrite(i,1);
}
}
String setNum(DateTime num){
char buffer[4];
sprintf(buffer, "%04d", num);
return String(buffer);
}
void loop()
{
int temp = DHT.read22(13);
DateTime time = rtc.now();
int cd = millis() + 20000;
String num = setNum(time.hour(), DEC);
for (int i = 2; i < 6; i++){
seg1.showNum(String(num[i - 2]).toInt());
digitalWrite(i, 0);
digitalWrite(i, 1);
}
if (cd >= millis())
{
Serial.println("Teplota " + temp);
cd = millis() - 10000;
}
}