Hello, I'm a student from korea.
I'm looking for someone who are willing to help me.
I'm making a solar tracker to graduate now, and I'm almost done except for one thing.
The thing is, to improve the efficiency of it, i need to use timer.
There is a servo motor to track the light of the sun, and it makes some power loss.
So, I want to activate the motor periodically not in real time.
In other words, I have no idea of how to utilize it at my coding
This is what i made so far. Please refer to this.
#include <Servo.h>
Servo tracker; // create servo object to control a servo
int eastLDRPin = 0; //Assign analogue pins
int westLDRPin = 1;
int eastLDR = 0; //Create variables for the east and west sensor values
int westLDR = 0;
int error = 0;
int calibration = 5; //Calibration offset to set error to zero when both
sensors receive an equal amount of light
int trackerPos = 60; //Create a variable to store the servo position
void setup()
{
tracker.attach(11); // attaches the servo on pin 11 to the servo object
}
void loop()
{
eastLDR = calibration + analogRead(eastLDRPin); //Read the value of each of the east and west sensors
westLDR = analogRead(westLDRPin);
if(eastLDR<0 && westLDR<0) //Check if both sensors detect very little light, night time
{
while(trackerPos<=160) //Move the tracker all the way back to face east for sunrise
{
trackerPos++;
tracker.write(trackerPos);
delay(3000);
}
}
error = eastLDR - westLDR; //Determine the difference between the two sensors.
direction
if(error>15) //If the error is positive and greater than 15 then move the tracker in the east direction
if(trackerPos<=160) //Check that the tracker is not at the end of its limit in the east direction
{
trackerPos= trackerPos+18;
tracker.write(trackerPos); //Move the tracker to the east
else if(trackerPos<=130)
{ trackerPos= trackerPos+9;
delay(1800000);
}
delay(3600000);
}
}