Hi there,
I am making a Solar Tracking System.
Basically what i have now is
- A Linear Actuator 12V DC
- 2 LDRs
- 1 Arduino Uno
- 1 H-Bridge L298N
I would like to control my Linear Actuator to move according to the light exposed to the 2 LDRs. I really have no idea how to continue.
I plan to have my starting position at the half way mark of the Linear Actuator and it will move according to the sunlight.
If east have more light, it will shift up.
If west have more light, it will shift downwards.
int ControlPin1 = 9; //
int ControlPin2= 10; //
void setup(){
Serial.begin(9600);
pinMode(ControlPin1, OUTPUT);
pinMode(ControlPin2, OUTPUT);
pinMode(BUTTON1,INPUT);
}
void InitialPosition(){
digitalWrite(ControlPin2, HIGH);
digitalWrite(ControlPin1, LOW);
delay(30000);
}
void retractActuator() {
digitalWrite(ControlPin2, LOW);
digitalWrite(ControlPin1, HIGH);
delay(15000); // max range is 30000, mid point is 15000
}
void stopActuator(){
digitalWrite(ControlPin2, LOW);
digitalWrite(ControlPin1, LOW);
delay(7000);
}
void loop(){
Serial.println( );// mid point is 15000s from max range.
//InitialPosition();
//delay(1000);
//stopActuator();
//delay(1000);
InitialPosition();
retractActuator();
stopActuator();
}
I use the delay to allow it to extend to max length , and retract to the minmum length. And the initial position i use (max length time - minimum length time)/2.
Is there any other way i can do it more efficiently, rather than depending on delays?
Most of the online examples uses Servo Motor which I don't intend to use.
Do advise.