I enabled timer and i want to set and reset pin in microcontroller every two hours, how to do that? i mean i want the pin on for 2 hours and off for another 2 hours.
Ok. Let's assume your timer generates interrupt every 100mS.
Now declare a variable as Int or Word (I.e. 16 bits) named Counter.
Declare another variable as 2-hour-flag.
In your 100mS isr, increment the Counter. Also if Counter is >= 72000, then SET 2-hour-flag.
Now in your main routine, setup a loop which checks 2-hour-flag. When it is SET, then TOGGLE your outputpin, and also set 2-hour-flag and Counter to zero.
That's your full code right there.
Of course if your timer interruots at a different rate, then calculate the '72000' accordingly.
- - - Updated - - -
Okay, slight error in above. The variable for Counter naturally has to be defined to be able to hold the count required. So select accordingly. Typical Int will not hold 72000, only upto 65535.