Quote Originally Posted by rocky79 View Post
Hello,
I am trying to use the pic as a clock timer that displays the time hour and minutes but also i would like it to have a featured timer that the user can set. The timer will activate a motor.
will the time be accurate enough?
I am using the pic basic pro and the usb programmer.
What's the easiest way to get this done? any suggestions is appreciated.
Thanks
I give u example of simple timer and clock where user can set when they want to high certain port of the PIC. THere is only two buttons need to be used. First button to toggle from one menu to other menu. For example if we press this button then we can change from setting minute to the hour setting menu. Other button function is to set(increase) the value of second, minute, hour and etc. But how accurate this timer is depend on the oscillator u use as Steve B had said before. Attached herewith is the code: Please advise if you have some input on this code. Thanks.

symbol second=2000
symbol second2=1000

second1 VAR BYTE
minute VAR BYTE
hour VAR BYTE
day VAR BYTE
time1 VAR BYTE
time2 VAR BYTE

second1=0
minute=0
hour=0
day=0
time1=0
time2=0
masa3=0


hourset:
Pause 200
LCDOut $FE,1
LCDOut "Set Hour"
LCDOut $FE,$C0
LCDOut "TIME:",DEC2 day,".",DEC2 hour,".",DEC2 minute,".",DEC2 second

IF PORTB.5=1 Then GoSub addhour
IF hour>23 Then hour=0
IF PORTB.6=1 Then GoSub time1set
GoTo hourset

hour1set:
Pause second2
LCDOut $FE,1
LCDOut "Set Time MotorOn1"
LCDOut $FE,$C0
LCDOut "Minute:",DEC2 time1

IF PORTB.5=1 Then GoSub addtime1
IF time1>59 Then time1=0
IF PORTB.6=1 Then GoSub time2set
GoTo time1set

time2set:
Pause second2
LCDOut $FE,1
LCDOut "Set Time MotorOn2"
LCDOut $FE,$C0
LCDOut "Day:",DEC2 time2

IF PORTB.5=1 Then GoSub addtime2
IF time4>99 Then time2=0
IF PORTB.6=1 Then GoSub changeday
GoTo time2set
End

addhour:
IF PORTB.5=1 Then GoSub timer
Return

timer:
second1=0
minute=minute+1
IF minute > 59 Then
minute=0
hour=hour+1
IF hour >23 Then
hour=0
day=day+1
IF day>30 Then
dayi=0
EndIF
EndIF
EndIF
Pause 500
Return

addtime1
IF PORTB.5=1 Then time1=time1+1
Pause 500
Return

addtime2
IF PORTB.5=1 Then time2=time2+1
Pause 500
Return

changeday:
IF PORTB.6=1 Then GoTo day


day:
Pause second
saat=saat+1
IF second1 >59 Then GoSub timer


LCDOut $FE,2
LCDOut "ON:",DEC2 time1,">",DEC2 time2,">"
LCDOut $FE,$C0
LCDOut "TIME:",DEC2 day,".",DEC2 hour,".",DEC2 minute,".",DEC2 second1


IF (minute=time1 OR minute=time2) Then High PORTB.7
IF (minute=time1+1 OR minute=time2+1) Then Low PORTB.7
Goto day