There's a lot of uses for a device that tracks the sun from, say, your window or something like that. Perhaps you want to set up a little solar panel, or you want to focus or reflect light onto a specific spot that might not get as much light otherwise. This project is very simple to make and you can put a lot of your own variation into it.
Electronics + Wiring
Putting together the wiring and electronics is pretty simple in theory and in practice. You're going to want to set up the servo directly in between and a little bit behind both of your photoresistors so that when the servo rotates it accurately faces the greatest source of light, as seen below.
After that, it's simply a matter of wiring everything together. Schematics are included towards the bottom of the page, but to put it simply, wire the respective servo wires to power, ground, and a digital pin and connect the photoresistors to different analog pins with a resistor for each one.
Coding
Code is also included towards the bottom of the page, but again, it's relatively simple so it can be briefly explained here.
Along with the servo motor, three int variables are initialized at the top of the page, left and right for the return value of each photoresistor and offset for the difference between the two.
In setup, the servo is attached and set to 90 degrees neutral. Also, the serial monitor is set up and two analog pins are set up to take inputs from the photoresistor. (spinnyboi is the name of my servo)
In the loop, both photoresistors are read every cycle, and the values of each photoresistor and the difference between them are printed. The offset is restricted to a range so that it will turn to the maximum or minimum if the light difference is really that great.
[90 - offset] will track the sun, so the servo will turn towards it.
[90 + offset] will turn away from the sun, which is useful if you wish to reflect the sun onto a specific point.
Finally, the delay at the end makes it so that the servo doesn't turn constantly and makes turns at a consistent, desirable interval.
Physical Stuff
This is the part where a lot of variation can come into the build. What I did personally was make a rotatable platform to put various objects on top of the servo. That is what will be shown here.
Start by putting a base on top of the servo motor, as seen below. The circular bit of cardboard isn't necessary, but it's something I stuck to the base to make the rotatable bit.
Then, layer circular pieces of carboard and stick them together. When placed into the circular base, it should be able to turn when some force is applied to it. The part that sticks out of the top (which is carboard here but really should be some kind of pin/metal) should be able to hold various object of light weight. Could put a lens, mirror, panel, etc all up on there, whatever suits your needs.
I used a piece of tinfoil wrapped around carboard as a makeshift mirror; place that onto the circle bit and place it into the base to get the image seen in the thumbnail for the page. A barrier is placed to focus light on the photoresistors and limit any light coming in from behind the servo.
Additions to this project that are not included here but could be fun on your own include but are not limited to:
- button to cycle through modes
- extra servo for vertical rotation
- manual control of the servo through switches.
Feel free to modify the project to your liking!


_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)




Comments