/*
PROJECT: https://wokwi.com/projects/378533060316140545
AUTHOR: Anastasia Cheremisova
https://github.com/space13pirate
*/
/*
Eng: Inclusion of the GyverTM1637 library, which allows you to easily manage the TM1637 indicator.
Рус: Включение библиотеки GyverTM1637, которая позволяет легко управлять индикатором TM1637.
*/
#include "GyverTM1637.h"
/*
Eng: Defining 2 constants CLK and DIO and assigning them values 2 and 3 respectively.
Рус: Определение 2 констант CLK и DIO и присваиваивание им значений 2 и 3 соответственно.
*/
const int CLK = 2;
const int DIO = 3;
/*
Eng: Creation of a disp object of type GyverTM1637 and initialization indicating the CLK and DIO pins to which the indicator is connected.
Рус: Создание объекта disp типа GyverTM1637 и инициализация с указанием пинов CLK и DIO, к которым подключён индикатор.
*/
GyverTM1637 disp(CLK, DIO);
int i = 0;
/*
Eng: The function is executed once when Arduino starts.
Рус: Функция выполняется 1 раз при старте Arduino.
*/
void setup() {
/*
Eng: Initializes a serial port connection at 9600 bps (will be used to output debug messages).
Рус: Инициализация соединения по последовательному порту со скоростью 9600 бит в секунду (будет использоваться для вывода отладочных сообщений).
*/
Serial.begin(9600);
/*
Eng: Set the indicator brightness to 7 (maximum brightness).
Рус: Установка яркости индикатора равной 7 (максимальная яркость).
*/
disp.brightness(7);
}
/*
Eng: The function runs indefinitely after the setup() function is executed.
Рус: Функция выполняется бесконечно после выполнения функции setup().
*/
void loop() {
disp.clear();
if (i < 5) {
// Градусы Цельсия
// + / -
int rand = random(0, 2);
if (rand == 0) {
disp.displayByte(0, 0x00);
} else {
disp.displayByte(0, 0x40);
}
// десятки
int c1 = random(1, 3);
disp.display(1, c1);
// единицы
int c2 = random(0, 10);
disp.display(2, c2);
// символ градуса
disp.displayByte(3, 0x63);
delay(1000);
disp.clear(); // Очистка индикатора.
// Вывод надписи "=".
byte equal[] = {_equal, _equal, _equal, _equal};
disp.displayByte(equal);
delay(1000);
// Градусы Кельвина
// + / -
if (rand == 0) {
disp.displayByte(0, 0x00);
} else {
disp.displayByte(0, 0x40);
}
int k = c1 * 10 + c2 + 273;
disp.displayInt(k);
delay(1000);
i++;
}
}