پاسخ : ساختن ساعت
[quote author=زوار link=topic=44026.msg259395#msg259395 date=1302926015]
با سلام جواب گرفتید؟من آماده ام اگر مشکلی دارید کمک کنم
[/صلی quote]دوست عزیز این تیکه از برنامه را ببین
[quote author=زوار link=topic=44026.msg259395#msg259395 date=1302926015]
با سلام جواب گرفتید؟من آماده ام اگر مشکلی دارید کمک کنم

[/صلی quote]دوست عزیز این تیکه از برنامه را ببین
کد:
Do Gosub Ds1307 Gosub Keypad Loop '------------------------------------------------------------------------------- Ds1307: Locate 1 , 1 : Lcd "tarikh:" : Locate 1 , 8 : Lcd Date$ Locate 2 , 1 : Lcd "time:" : Locate 2 , 8 : Lcd Time$ Locate 3 , 2 : Lcd " enter year" : Gosub Getdatetime Return '------------------------------------------------------------------------------- Keypad: Gosub Get_key If Key = 10 Then Year = Year_1000 * 1000 Temp_word = Year_100 * 100 Year = Year + Temp_word Temp_word = Year_10 * 10 Year = Year + Temp_word Year = Year + Year_1 'If Year > 2000 And Year < 2050 Then Goto Mounth 'Exit Do If Year <= 2000 Or Year => 2050 Then Cls Lcd " Year Error" Locate 2 , 1 Lcd "Year=2001...2050" Wait 3 Cls Lcd "Enter Year:" Locate 2 , 1 Lcd Year End If End If If Key < 10 Then Year_1000 = Year_100 Year_100 = Year_10 Year_10 = Year_1 Year_1 = Key Year = Year_1000 * 1000 Temp_word = Year_100 * 100 Year = Year + Temp_word Temp_word = Year_10 * 10 Year = Year + Temp_word Year = Year + Year_1 Cls Lcd "Enter Year:" Locate 2 , 1 Lcd Year End If Cls Lcd "Enter Month:" Locate 2 , 1 Lcd Month 'Loop Return '------------------------------------------------------------------mounth----- Mounth: Key = Getkbd() If Key = 10 Then Month = Month_10 * 10 Month = Month + Month_1 'If Month > 1 And Month < 13 Then Exit Do If Month = 0 Or Month > 12 Then Cls Lcd " Month Error" Locate 2 , 1 Lcd "Month=1...12" Wait 3 Cls Lcd "Enter Month:" Locate 2 , 1 Lcd Month End If End If If Key < 10 Then Month_10 = Month_1 Month_1 = Key Month = Month_10 * 10 Month = Month + Month_1 Cls Lcd "Enter Month:" Locate 2 , 1 Lcd Month End If Cls Lcd "Enter Day:" Locate 2 , 1 Lcd Day End '-------------------------- Get_key: Key = Getkbd() Do Temp_byte = Getkbd() Loop Until Temp_byte <> 16 Select Case Temp_byte Case 0 Key = 1 Case 1 Key = 2 Case 2 Key = 3 Case 3 Key = 11 Case 4 Key = 4 Case 5 Key = 5 Case 6 Key = 6 Case 7 Key = 11 Case 8 Key = 7 Case 9 Key = 8 Case 10 Key = 9 Case 11 Key = 11 Case 12 Key = 11 Case 13 Key = 0 Case 14 Key = 11 Case 15 Key = 10 End Select 'Cls Do Temp_byte = Getkbd() Loop Until Temp_byte = 16 Return '------------------------------------------------------------------------------ Getdatetime: I2cstart I2cwbyte Ds1307w I2cwbyte 0 I2cstart I2cwbyte Ds1307r I2crbyte _sec , Ack I2crbyte _min , Ack I2crbyte _hour , Ack I2crbyte Weekday , Ack I2crbyte _day , Ack I2crbyte _month , Ack I2crbyte _year , Nack I2cstop _sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour) _day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year) Return Setdate: _day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year) I2cstart I2cwbyte Ds1307w I2cwbyte 4 I2cwbyte _day I2cwbyte _month I2cwbyte _year I2cstop Return SetTime: _sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour) I2cstart I2cwbyte Ds1307w I2cwbyte 0 I2cwbyte _sec I2cwbyte _min I2cwbyte _hour I2cstop Return
دیدگاه