#include <Arduino.h>
#include <DHT.h>
#include "TM1637.h"

#define CLK 2
#define DIO 3
#define DHT_PIN 5
#define LIT_F SEG_A | SEG_F | SEG_G | SEG_E
#define LIT_H (SEG_F | SEG_G | SEG_B | SEG_E | SEG_C)
#define LIT_O SEG_E | SEG_G | SEG_C | SEG_D
#define LIT_SPACE 0

DHT dht(DHT_PIN, DHT22);
TM1637Display display(CLK, DIO);

void setup()
{
  display.setBrightness(7);
  dht.begin();
}

void print_temperature(TM1637Display& display, DHT& dht)
{
    const uint8_t F_TIP[] = {SEG_A | SEG_F | SEG_G | SEG_B, LIT_F};
    display.clear();

    display.showNumberDec(dht.readTemperature(true), false, 2, 0);
    display.setSegments(F_TIP, 2, 2);
}

void print_humidity(TM1637Display& display, DHT& dht)
{
    const uint8_t H_TIP[] = {SEG_A | SEG_F | SEG_G | SEG_B, LIT_O};
    display.clear();

    display.showNumberDec(dht.readHumidity(), false, 2, 0);
    display.setSegments(H_TIP, 2, 2);
}

void loop()
{
    print_temperature(display, dht);
    delay(2000);

    print_humidity(display, dht);
    delay(2000);
}
4-Digit Display