وهذا الكود :
'
' *
program prayartime
dim y ,L1 as longint
dim D,L,ty,Lambda,Obliquity ,Alpha,ST,Dec1,noon, utnoon,dhrtime,asrtime,asralt,durinalarc,marbtime, EshaArc,M,eshatime,fajrtime,shroq ,ard,tol as float
i ,farq as byte
day,month_,dhr,dhr1,asr,asr1,fjr,fjr1,marb,marb1,e sha,esha1 as byte
dim x,x1 as byte[48]
sub procedure awqat()
ard=36.334
tol=43.2
farq=3
D=((367*y)-(floor((1.75)*(y+floor((month_+9)/12))))+floor(275*(month_/9))+day-730531.5)
L=280.461+0.9856474*D
L1=L
L=L-L1
L1=L1 mod 360
L=L1+L
M = 357.528+0.9856003*D
L1=M
M=M-L1
L1=L1 mod 360
M=L1+M
Obliquity = 23.439-0.0000004*D
Lambda = L+1.915*sin(M*PI/180)+0.02*sin(2*M*PI/180)
L1=Lambda
Lambda =Lambda-L1
L1=L1 mod 360
Lambda =L1+Lambda
Alpha=atan(cos(Obliquity *PI/180)*tan(Lambda*PI/180))*180/PI
Alpha=Alpha-(360*floor(Alpha/360))
Alpha=Alpha+90*(floor(Lambda/90)-floor(Alpha/90))
ST=100.46 + 0.985647352 *D
L1=ST
ST=ST-L1
L1=L1 mod 360
ST=L1+ST
Dec1=asin(sin(Obliquity*PI/180)*sin(Lambda*PI/180))*180/PI
noon=Alpha-ST
if noon>=0 then
noon=fabs(noon)
L1=fabs(noon)
noon=noon-L1
L1=L1 mod 360
noon=noon+L1
else
noon=fabs(noon)
L1=fabs(noon)
noon=noon-L1
L1=L1 mod 360
noon=noon+L1
noon=360-noon
end if
utnoon=noon-tol
dhrtime=(utnoon/15)+farq
dhr1=dhrtime
dhrtime=dhrtime-dhr1
dhr=floor(dhrtime*60)
dhrtime=(utnoon/15)+3
asralt=atan(1+tan((ard-Dec1)*PI/180))*180/PI
asrtime=acos((sin((90-asralt)*PI/180)-sin(Dec1*PI/180)*sin(ard*PI/180))/(COS(Dec1*PI/180)*COS(ard*PI/180)))*180/PI
asrtime=(asrtime/15)+dhrtime
asr1=asrtime
asrtime=asrtime-asr1
asr=floor(asrtime*60)
durinalarc=acos((SIN(-0.8333*PI/180)-SIN(Dec1*PI/180)*SIN(ard*PI/180))/(COS(Dec1*PI/180)*COS(ard*PI/180)))*180/PI
shroq=dhrtime-durinalarc/15
marbtime=dhrtime+durinalarc/15
marb1=marbtime
marbtime=marbtime-marb1
marb=floor(marbtime*60)
EshaArc= acos((SIN(-18*PI/180)-SIN(Dec1*PI/180)*SIN(ard*PI/180))/(COS(Dec1*PI/180)*COS(ard*PI/180)))*180/PI
eshatime=dhrtime+EshaArc/15
esha1=eshatime
eshatime=eshatime-esha1
esha=floor(eshatime*60)
fajrtime=dhrtime-EshaArc/15
fjr1=fajrtime
fajrtime=fajrtime-fjr1
fjr=floor(fajrtime*60)
dhr=dec2bcd(dhr)
dhr1=dec2bcd(dhr1)
fjr=dec2bcd(fjr)
fjr1=dec2bcd(fjr1)
if asr1>12 then
asr1=asr1-12
end if
if marb1>12 then
marb1=marb1-12
end if
if esha1>12 then
esha1=esha1-12
end if '
asr=dec2bcd(asr)
asr1=dec2bcd(asr1)
marb=dec2bcd(marb)
marb1=dec2bcd(marb1)
esha=dec2bcd(esha)
esha1=dec2bcd(esha1)
end sub
dim Soft_I2C_Scl as sbit at RC3_bit
dim Soft_I2C_Sda as sbit at RC4_bit
dim Soft_I2C_Scl_Direction as sbit at TRISC3_bit
dim Soft_I2C_Sda_Direction as sbit at TRISC4_bit
dim sec,min,hr,week_day,dday,mn,year as short
sub procedure Read_Time(dim byref sec, min, hr, week_day, dday, mn, year as short)
Soft_I2C_Start()
Soft_I2C_Write(0xD0)
Soft_I2C_Write(0)
Soft_I2C_Start()
Soft_I2C_Write(0xD1)
sec =Soft_I2C_Read(1)
min =Soft_I2C_Read(1)
hr =Soft_I2C_Read(1)
week_day =Soft_I2C_Read(1)
dday =Soft_I2C_Read(1)
mn =Soft_I2C_Read(1)
year =Soft_I2C_Read(0)
Soft_I2C_Stop()
end sub
sub procedure Write_Time(dim address1 as short,dim data_wr as short)
Soft_I2C_Start()
Soft_I2C_Write(0xD0)
Soft_I2C_Write(address1)
Soft_I2C_Write(data_wr)
Soft_I2C_Stop()
end sub
'
main:
TRISB = 0
PORTB = 0
trisc.0=0
trisc.1=0
trisc.2=0
trisa.0=0
Soft_I2C_Init()
while true
Read_Time(sec,min,hr,week_day,dday,mn,year)
day=bcd2dec(dday)
month_=bcd2dec(mn)
y=2010
awqat()
for i=0 to 47
x[i]=0
x1[i]=0
next i
for i = 0 to 7
x[i]=dhr.i
x1[i]=esha.i
next i
for i = 0 to 7
x[i+8]=dhr1.i
x1[i+8]=esha1.i
next i
for i = 0 to 7
x[i+16]=fjr.i
x1[i+16]=marb.i
next i
for i = 0 to 7
x[i+24]=fjr1.i
x1[i+24]=marb1.i
next i
for i = 0 to 7
x[i+32]=min.i
x1[i+32]=asr.i
next i
for i = 0 to 7
x[i+40]=hr.i
x1[i+40]=asr1.i
next i
for i = 0 to 47
portb.0=x[i]
portc.0=x1[i]
portb.1=0
portc.1=0
delay_us(20)
portb.1=1
portc.1=1
next i
porta.0=1
delay_ms(300)
portb.2=0
portc.2=0
delay_us(20)
portb.2=1
portc.2=1
porta.0=0
delay_ms(300)
wend
end.
--------------------------------------------------------------------------------
Read more: http://www.qariya.com/vb/showthread....#ixzz1h0ydkNFe