DS1307 & TM1637 with Arduino
Making a Digital clock with Arduino boards. (ماژول ساعت DS1307)
• Arduino board
• DS1307 RTC Module I2C (SDA and SCL)
• TM1637 7-segment I2C (CLK and DIO)
The DS1307 uses I2C Protocol to communicate with arduino.
There are a lot of examples on the Web to show how to use Wire library.
The Wire library makes DS1307 RTC easier to use for getting/setting the time.
Driver IC: DS1307 real clock
SCL: Analog 5 (clock line)
SDA: Analog 4 (data line)
Voltage: +3.3V to +5V
GND: GND of Arduino
Typically you want to use 2.2K or 2.4K resistors between each of the SDA and SCL pins and +3.3v of arduino.
For my module, I do NOT need pull-up resistors.
The TM1637 also uses I2C Protocol to communicate with arduino.
Driver IC: TM1637 display 7-Segment
Voltage: +3.3V to +5V
Interface: I2C
CLK: Digital 9
DIO: Digital 8
GND: GND of Arduino
8 adjustable luminance levels
The CLK and DIO on display can connect to any of arduino digital pins. I use for DIO pin the D8 and for CLK pin the D9 Pins.
// DS1307 & TM1637 7-segment with Arduino #include #include "TM1637.h" // pins definitions for TM1637 and can be changed to other ports #define CLK 2 #define DIO 3 TM1637 tm1637(CLK,DIO); // Holds current clock time RTC_DS1307 RTC; DateTime theTime; int8_t TimeDisp[] = {0xff, 0xff, 0xff, 0xff}; void setup() { Serial.begin(9600); if (!RTC.begin()) { Serial.println("Couldn't find RTC"); while(1); } if (!RTC.isrunning()) { Serial.println("RTC is NOT running!"); RTC.adjust(DateTime(F(__DATE__), F(__TIME__))); } tm1637.init(); tm1637.set(2); // TYPICAL = 2, DARKEST = 0, BRIGHTEST = 7; tm1637.display(0,10); // show A B C D for testing tm1637.display(1,11); tm1637.display(2,12); tm1637.display(3,13); delay(3000); } int hour, minute, second; unsigned char ClockPoint = 1; void loop() { DateTime theTime = RTC.now(); second = theTime.second(); // get seconds minute = theTime.minute(); // get minutes TimeDisp[0] = minute / 10; TimeDisp[1] = minute % 10; TimeDisp[2] = second / 10; TimeDisp[3] = second % 10; tm1637.display(0,TimeDisp[0]); tm1637.display(1,TimeDisp[1]); tm1637.display(2,TimeDisp[2]); tm1637.display(3,TimeDisp[3]); Serial.print("Set to "); Serial.print(hour); Serial.print(":"); Serial.print(minute); Serial.print(":"); Serial.print(second); Serial.println(); ClockPoint = (~ClockPoint) & 0x01; if(ClockPoint)tm1637.point(POINT_ON); else tm1637.point(POINT_OFF); delay(1000); }
Continue….
hi, i done this your project and it was successful but time is in minute and seconds i want it in hour and minute .pls help what you did.