MEKACI:
I have x6 LDR(s) that are divided by blocks between each other. 1st LDR front left - 2nd LDR middle - 3rd ldr front right position etc. And if the bright light source is on the 1st LDR then turn left while going forward until the light source position comes to middle 2nd ldr
Turning in the direction of a light source should be straightforward
and once the light source is on the 2nd ldr then go forward until it comes closer to light source.
If you have not included experimental data for that light source in your program then this will be a very haphazard process. You could make a note of the light intensity when you are first aimed at the light and you could continue towards the light until the intensity increases by a certain amount. But you would have no means to know how far from the light you are and you might even bump into it before you get to the desired intensity.
In addition, I need to find a reliable way to make dc motors turn right/left until some point then stop.
That is reasonably straightforward. If the light detected by the left sensor is brighter turn to the left and measure the light again. If the two measures are the same stop turning.
Ultrasonic sensor cannot measure distance between light source and the robot where LDRs are located. And at the given task us, it wants us to find the distance between light source and the robot (with LDR help) then follow it and show the distance on the lcd/oled etc.
I have made lot's of research myself first but I didn't get some points so I wanted to ask you here.
You CANNOT tell how far you are from a light using a single LDR unless you have made experiments with that exact same light. No amount of wishful thinking will change that.
As someone else suggested if you have two sensors some distance apart which can be angled towards the light and so you can measure the angle between them you could then use trigonometry to calculate the distance. However unless the distance between the sensors is large you won't get accurate distances for long ranges - the change in angle will be very small until the light is very close.
For your 2nd question Robin.
Distance measurement will not be perfect with LDR but as long as I can measure a raw distance, that is fine.
You need to say what amount of error is acceptable. For example would an error of +/- 2 metres be OK?
...R