Here is a simple solar tracker, made with Arduino …
It ‘s just a draft, a starting point to be improved for building new projects.
The idea is very simple. Using two photoresistors (LDRs), one pointing slightly to the right and the other slightly to the left, let’s read the values and move a continuous rotation servo in the direction of the photoresistor receiving more light, until the brightness is about the same on both LDRs.
The end result is what we see in the following video:
As you can see I used Arduino Mini Pro, but nothing change using Arduino UNO. The only difference is that feeding the Arduino Pro Mini I had to use an external regulator, because the inside is not enough to drive the servo.
But let’s get to the list of materials needed:
1 – An Arduino UNO board (or any other compatible)
2 – Two 20K LDR photoresistors (with a few adjustments may also fit other values)
3 – Two 4.7K resistors (with different lighting conditions you can use different values)
4 – A continuous rotation servo. (Difficult and/or expensive to find, so I modified a standard servo following the directions found at this link
5 – One 9V battery, a breadboard, plastic holders and little else
The components must be connected to Arduino as follows:
As you see, everything is very simple.
If you want to download the fritzing file, this is the link.
http://fritzing.org/media/fritzing-repo/projects/i/isarduino-micro-robot-inseguitore-solare-con-ardui/fritzing/ISArduino.fzz
Let’s take a look at the following code:
/* ISArduino 0.1 Arduino Solar Tracker by Luca Soltoggio - 2012 http://arduinoelettronica.wordpress.com */ #include <Servo.h> #include <Narcoleptic.h> /* A library that allows to put the microcontroller in standby while in idle (delay), saving lot of energy. You can safely remove it (but in this case you have to replace the last staement Narcoleptic.delay(15) with delay(15). */ Servo myservo; int Value; int Center=105; /* The variable Center represents the centering value of the servo. In my case it is 105, while usually it is 90. With this value, the servo must stop running. */ void setup() { Serial.begin(9600); myservo.attach(9); // Attach servo to PIN 9 } void loop() { int sensorValue = analogRead(A0); // Read left LDR value int sensorValue2 = analogRead(A1); // Read left LDR value Value=(sensorValue-sensorValue2)/10; /* Compute the differnce between the two sensors */ if (Value==0) myservo.detach(); else myservo.attach(9); /* Detach servo if idle (for energy saving) */ if (Value>10) Value=10; if (Value<-10) Value=-10; /* Limits the maximum difference between -10 and + 10 (in order to avoid an excessive speed) */ Serial.println(Value); // Debug myservo.write(Center+Value); /* If "Value" is positive, move the servo to right, else to left The speed is directly proportional to the absolute value of "Value" */ Narcoleptic.delay(15); /* Rather than using a simple delay, we use this to save energy You can eventually replace with delay(15) */ }
The code is very simple and self-explanatory, so I will not dwell too much.
If you want to download the Arduino sketch, it can be found here:
http://fritzing.org/media/fritzing-repo/projects/i/isarduino-micro-robot-inseguitore-solare-con-ardui/code/inseguitore_solare.ino
Below is the link to the page of the Fritzing project:
http://fritzing.org/projects/isarduino-micro-robot-inseguitore-solare-con-ardui/