+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Advanced Member level 1
    Points: 3,016, Level: 12
    Jestin_cubetech's Avatar
    Join Date
    Jun 2012
    Posts
    499
    Helped
    74 / 74
    Points
    3,016
    Level
    12
    Blog Entries
    6

    servo based dual axis solar tracker

    servo based dual axis solar tracker






    2 servo motor
    4 LDR
    PIC16F877A
    ----------------------------------------------
    One man's fault is other man's lesson...
    ----------------------------------------------

    •   AltAdvertisment

        
       

  2. #2
    Newbie level 3
    Points: 27, Level: 1

    Join Date
    May 2013
    Posts
    4
    Helped
    0 / 0
    Points
    27
    Level
    1

    Re: servo based dual axis solar tracker

    hi
    i try to make this project ,the mechanical constraction i completed but,i have some problem about software ccs c code, i desire from you the codes in 16f877a .please help me .
    thanks

    •   AltAdvertisment

        
       

  3. #3
    Advanced Member level 1
    Points: 3,016, Level: 12
    Jestin_cubetech's Avatar
    Join Date
    Jun 2012
    Posts
    499
    Helped
    74 / 74
    Points
    3,016
    Level
    12
    Blog Entries
    6

    Re: servo based dual axis solar tracker

    http://www.instructables.com/id/Arduino-Solar-Tracker/

    Code:
    #include <Servo.h> // include Servo library 
    
    Servo horizontal; // horizontal servo
    int servoh = 90; // stand horizontal servo
    
    Servo vertical; // vertical servo 
    int servov = 90; // stand vertical servo
    
    // LDR pin connections
    // name = analogpin;
    int ldrlt = 0; //LDR top left
    int ldrrt = 1; //LDR top rigt
    int ldrld = 2; //LDR down left
    int ldrrd = 3; //ldr down rigt
    
    void setup()
    {
      Serial.begin(9600);
    // servo connections
    // name.attacht(pin);
      horizontal.attach(9); 
      vertical.attach(10);
    }
    
    void loop() 
    {
      int lt = analogRead(ldrlt); // top left
      int rt = analogRead(ldrrt); // top right
      int ld = analogRead(ldrld); // down left
      int rd = analogRead(ldrrd); // down rigt
    
      int dtime = analogRead(4)/20; // read potentiometers
    int tol = analogRead(5)/4;
    
    int avt = (lt + rt) / 2; // average value top
    int avd = (ld + rd) / 2; // average value down
    int avl = (lt + ld) / 2; // average value left
    int avr = (rt + rd) / 2; // average value right
    
    int dvert = avt - avd; // check the diffirence of up and down
    int dhoriz = avl - avr;// check the diffirence og left and rigt
    
    if (-1*tol > dvert || dvert > tol) // check if the diffirence is in the tolerance else change vertical angle
    {
    if (avt > avd)
    {
    servov = ++servov;
    if (servov > 180)
    {
    servov = 180;
    }
    }
    else if (avt < avd)
    {
    servov= --servov;
    if (servov < 0)
    {
    servov = 0;
    }
    }
    vertical.write(servov);
    }
    
    if (-1*tol > dhoriz || dhoriz > tol) // check if the diffirence is in the tolerance else change horizontal angle
    {
    if (avl > avr)
    {
    servoh = --servoh;
    if (servoh < 0)
    {
    servoh = 0;
    }
    }
    else if (avl < avr)
    {
    servoh = ++servoh;
    if (servoh > 180)
    {
    servoh = 180;
    }
    }
    else if (avl == avr)
    {
    // nothing
    }
    horizontal.write(servoh);
    }
    delay(dtime);
    }
    ----------------------------------------------
    One man's fault is other man's lesson...
    ----------------------------------------------

    •   AltAdvertisment

        
       

  4. #4
    Newbie level 3
    Points: 27, Level: 1

    Join Date
    May 2013
    Posts
    4
    Helped
    0 / 0
    Points
    27
    Level
    1

    Re: servo based dual axis solar tracker

    thank you very much for help

--[[ ]]--