I want to make a program for an EV3 solar heliostat.

It consists of two motors and a color sensor. I want it to follow the light. The station is fixed.

EV3SolarStation pdf

closed as too broad by Alexander O'Mara, chicks, Ankit Sharma, LegoSonicBoy, David Lechner Jan 4 at 5:01

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • i want it to follow light .also the station is fixed – morad Dec 19 '18 at 19:55
  • 1
    Can you provide more details then this, currently it's too vague – Ankit Sharma Dec 20 '18 at 3:37
  • 1
    Hi @morad ! Could you please provide either a detailed description or a picture of this solar station? Knowing the orientation of the motors and the general idea would allow us to help you better. Thanks! – zovits Dec 20 '18 at 9:44

As far as I see, you have two possible ways of accomplishing this, given that you have already built an Altazimuth mount or any other two-dimension mount from the two motors that can hold the color sensor and point it in any direction.


This is the harder way but it grants neater results. It involves taking a precise measurement of the device's location and orientation, setting up a known orientation for both motors as zero, and porting a known solar-tracking algorithm to the EV3 (like this or this). The resulting setup then must not be shut down, moved or rotated since the control of the motors is done by an algorithm which only takes into account the starting conditions (spatial and temporal) and the elapsed time. The accuracy of the EV3 internal clock may also factor into the precision if the project is to be left running for a long time. As an added bonus, you don't need the color sensor at all.

Using iterative methods

This approach requires a lot less intial setup but offers a not-so polished end result. The basic premise is using the color sensor to get an estimation of the amount of the light incoming from the current direction, then comparing it with the measurement(s) from some other direction(s), finally turning toward the higher value.

There are two problems to be solved here: first, the current position of the Sun (or its equivalent if you are indoors) must be found among all possible orientations. This is an example of the mathematical operation known as finding the global maxima of a two-dimensional function on a constrained range, where the two input dimensions are the altitude and the azimuth and the output is the measured amount of light coming from the given direction.

Then, the software must account for the inevitable changes due to the relative movement of the Sun in the sky. Since you have chosen this way and not the first (Calculation), you can not know in advance which direction the Sun will move in. So you can only attempt to find it again after a set amount of time or after the measured brightness drops to (or by) a specified amount.

There are countless ways this approach can be fine-tuned, depending on the precision of the motors, the precision, update rate and measuring range of the sensor, the amount of location and orientation information known beforehand, the required precision of the resulting system, the allowed complexity of the software, etc.

The most basic and a very ineffective system would consist of the following pseudocode:

repeat forever:
    oldBrightness = read(colorSensor)
    movementXAxis = getRandom(-10, 10) // decide on a random direction to turn to
    movementYAxis = getRandom(-10, 10)
    moveXAxis(movementXAxis)           // turn to the new direction
    newBrightness = read(colorSensor)
    if(newBrightness < oldBrightness)  // if the new direction is worse than the old
        moveXAxis(-movementXAxis)      // then turn back to the old direction
    wait(someTime)                     // bask in the sun for a while :)

This of course can be updated with more advanced logic, including but not limited to

  • paying attention to the amount of difference between the old and new measurements
  • moving first in larger steps to get a coarse direction and then refine it further with smaller steps
  • staying pointed in a direction longer if the brightness is higher there
  • moving continuously in one direction while the brightness is increasing and stopping when it starts to fall
  • storing directions and corresponding measurements to create a 2D function which can be analysed using mathematical methods to find the best result
  • storing historical data to predict and account for changes in the long run
  • (but by now you are practically in the complexity region of the Calculation-way)
  • etc.

Consult the relevant Wikipedia page for some advanced reading material and as a starting point if you are interested in learning more about the applicable algorithms.

  • I use mindstorm program for ev3 .I am greatful for you but can you give me a program on mindstorm.i put a link for solar station.thanks very much – morad Dec 21 '18 at 19:25
  • @morad sorry, your link seems broken, the browser days the file is too big to display and the PDF reader says it's invalid. – zovits Dec 21 '18 at 20:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.