attachInterrupt() or external interrupt

Hi guys,
I am new to Arduino and this forum.

I am experimenting with the RTC ds1307 and external interrupt. The program I wrote increments numbers from one to 10 with a 2sec delay and when I press a button connect to an input I the program to interrupt, which i got working perfectly. The problem is, I cant figure out how read the time from the RTC and serial. print it to time stamp the push button.

Please for some guidance.

Moved to a more suitable location


Is this the description and behavior of your project?.

1. There are Arduino UNO, DS1307 RTC, push button, and 2 cc-type 7-segment display unit. The connection diagram is like this (Fig-1):

2. After uploading the sketch of Step-3, the system works in this way:
(1) The display initially shows 0; after 2-sec delay as counted by DS1307, the display shows 1; after another delay of 2-sec, the display shows 2 and so on until the display shows 10 and then recycles. (There is no use of delay(2000); function for the 2-sec interval.)

(2) While counting from 0 to 10, the push button (K1) is pressed; the MCU is interrupted; the program will halt; the display will freeze at the current count; the time (say: t1) at which the push has been pressed will be shown on the Serial Monitor.

3. This is the sketch which does not correctly register t1 of Step-2(2). Please, help!
(Please, post your codes.)


My guess but why not simple pole the button, you are probably getting a bunch of interrupts caused by the button bounce. Interrupts are critical and precious commodity. It appears you may not have exited the interrupt routine properly. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!

Please, post your codes whatever you have tried.