Solar Panel keep rotating anticlockwise

I'm still new to this programming world. Can someone please help me. I'm working on this project for solar panel dual axiswhich run in two mode(Manual/Auto).Maunual mode will be control by using Labview. I've installed 4 LDR to act as a sensor on all the 4 corners of the panel. My solar panel keep rotating anticlockwise direction after getting instruction from the attach coding coding after uploading it in the Arduino board(Arduino Pro Mini 5v,16Mhz ATmega328).

I would like to know if it's the coding or the hardware problem?

Pease help me.

solar.ino (10.1 KB)

Try simplifying the tests like this - and put in limits (I may not have the correct limit values)

if (dvert > SensitivityV) {
    if((avt > avd)  {
       pos--;
       if (pos < 0) {
          pos = 0;
       }
    }
    else {
       pos ++;
       if (pos > 180) {
          pos = 180;
       }    
    }
}
myservo.write(pos);// write value to servo

...R

It works pretty well when I upload the coding below just for testing.

Testing.ino (989 Bytes)

Fiq89:
It works pretty well when I upload the coding below just for testing.

Can we assume the problem is solved ?

...R

Hi,
Can you post a picture of your panel and LDR placement please.
It seems odd to place the LDRs at the corners of the PV instead of together with shadow boards between them.
Do you have shade tubes on them so they only see light from directly in front of them?

Tom.... :slight_smile:

Hi TomGeorge,

I even cover all of them with black tapes on the LDR. still the panel keep rotating anti-clockwise instead of staying stationary.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom...... :slight_smile:

Fiq89:
I even cover all of them with black tapes on the LDR. still the panel keep rotating anti-clockwise instead of staying stationary.

So what did you mean when you said in Reply #2

It works pretty well when I upload the coding below just for testing

It seems to me that the key will lie in the difference between that working test code and the code that fails.

Post both of them.

...R

Hi,
When you wrote this sketch, did you write sections and test them before going to the next section.

Have you got a sketch that just does the panel position in one axis only and NOTHING else, to see if your logic works and how your LDRs respsond.

If not, then I suggest you do this, it may sound like a step backwards, but making your program as modules helps in debugging and integration.

Use Serial to help debug, but forget about sending any commands, just monitor your sketch variables.

Also please, a picture and circuit diagram of your project so we can see how your LDRs are wired and hence how your skectch should see its input.

Tom...... :slight_smile: