Hello everyone! Nowadays i’m curios about arduino. However for now i don’t have any arduino board. I have made some calculations on visual c# to find the solar position and i suceeded. Now I’m trying to apply these codes to arduino. I want you to check my code

```
void loop() {
double YSZM, d, B, ZD, ZDF, YSS, YS, SA, EgimA, Alti, Zenit, SunR, SunS, AzimA;
double Lati = 35.85163; // "-" for south
double Longi = 37.64879; // "-" for west
double hour,minute,second; //Localtime
hour=15;
minute=5;
second=54;
d = 315; //Day of The Year
int utcD=2; //GMT
//These values are just sample, these can be get from RTC module
//Begining the calculation...
YSZM = 15 * utcD;
YS = (hour) + (minute/60) + (second/3600); //converting the local time into hour format...
//these are some time correction equations..
B = ((double)360 / 365) * (d - 81);
ZD = (9.87 * SinD(2 * B)) - (7.53 * CosD(B)) - (1.5 * SinD(B));
ZDF = 4 * (Longi - YSZM) + ZD;
YSS = YS + (ZDF / 60); // Local Solar Time (in hours)
SA = 15 * (YSS - 12); //Hour Angle
EgimA = ASinD(SinD(23.45) * SinD(B)); // Declination angle
Alti = ASinD(SinD(EgimA) * SinD(Lati) + CosD(EgimA) * CosD(Lati) * CosD(SA)); //Elevation angle or Altitude... 0(zero) is the horizon. 90 is the top.
Zenit = 90 - Alti; //Zenith angle...
//Azimuth Angle calculation.. 0 is North, 90 is East, 180 is South, 270 is West,
AzimA = ACosD( ((SinD(EgimA) * CosD(Lati)) + (-CosD(EgimA) * SinD(Lati) * CosD(SA))) / CosD(EgimA));
if (SA > 12)
{
AzimA = 360 - AzimA;
}
SunR = 12 - (double)1 / 15 * ACosD(-TanD(Longi) * TanD(EgimA)) - (double)ZDF / 60; //SUNRISE in hours
SunS = 12 + (double)1 / 15 * ACosD(-TanD(Longi) * TanD(EgimA)) - (double)ZDF / 60; //SUNSET in hours
}
//these are the converted version of sin cos tan acos asin in degrees...
double SinD(double deg){
return sin(deg*Pi/180);
}
double CosD(double deg){
return cos(deg*Pi/180);
}
double ACosD(double deg){
return acos(deg) * 180 / Pi;
}
double ASinD(double deg){
return asin(deg) * 180 / Pi;
}
double TanD(double deg){
return tan(deg*Pi/180);
}
```

waiting for your suggestions to improve the code. And a question… Can i use Azimuth and elevation angles to point a solar cell with pan tilt servo motors?