Простые в сборке часы.
Корпус часов применен от упаковки детской соски известной марки (Avent).
Список деталей:
1. Модуль часов RTC1302
2. Модуль LED индикации зеленый на TM1637
3. м/к Atmega328P
4. кварц 16МГц
скетч
// Часы на RTC-модуле DS1302 и индикацией на TM1637
#include <Arduino.h>
#include <DS1302.h>
#include <TM1637.h> // CLK DIO VCC GND
#define CLK 11
#define DIO 12
TM1637 Display1(CLK, DIO);
int8_t DigTime[] = {0,1,2,3};
// Init the DS1302 (RST, DAT, CLK)
DS1302 rtc(10,9,8);
// Init a Time-data structure
Time t;
void setup()
{
// Установка времени на RTC-модуле
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
// Setup Serial connection
// Serial.begin(9600);
// The following lines can be commented out to use the values already stored in the DS1302
// rtc.setTime(11, 13, 00); // Set the time to 12:00:00 (24hr format)
// rtc.setDate(01, 06, 2018); // Set the date to August 6th, 2010
Display1.set(7);
Display1.init();
Display1.display(DigTime);
}
void loop()
{
// Get data from the DS1302
t = rtc.getTime();
// Send date over serial connection
// Serial.print(t.date, DEC);
// Serial.print(".");
// Serial.print(t.mon, DEC);
// Serial.print(".");
// Serial.println(t.year, DEC);
// Send Day-of-Week and time
// Serial.print(t.hour, DEC);
// Serial.print(":");
// Serial.print(t.min, DEC);
// Serial.print(":");
// Serial.println(t.sec, DEC);
// Wait one second before repeating :)
delay(1000);
DigTime[3] = t.min %10 ;
DigTime[2] = (t.min % 100) / 10 ;
DigTime[1] = t.hour % 10 ;
DigTime[0] = (t.hour % 100) / 10 ;
if ((t.hour > 6) && (t.hour) < 22) {
Display1.set(7); // день
}
else {
Display1.set(2); // ночь
}
if ((t.sec % 2) == 0)
{
Display1.point(POINT_OFF);
}
else
{
Display1.point(POINT_ON);
}
Display1.display(DigTime);
}


