FIELDING
Published © GPL3+

Solar Panel Sun Tracker - Phone Charger

Fun and easy green robot! Build a sun tracking solar array in under an hour. Bonus: charge your phone with free clean energy!

IntermediateFull instructions provided1 hour155,196
Solar Panel Sun Tracker - Phone Charger

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Servos (Tower Pro MG996R)
9gram servo that doesn't need external power
×1
Photo resistor
Photo resistor
×2
Resistor 10k ohm
Resistor 10k ohm
×2
2.5V to 5V boost converter - USB Adapated
×1
Solar Panel - Hobby Size
Any small panel will do, the higher the output the better, but keep it small and light
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

suntracker_bb_4YYw7HZDM9.png

Code

Sun Tracker

Processing
//Sun Tracker Sketch 
//
//This sketch is designed for use with a 9gram servo, able
//to be powered directly from the Arduinio without an external 
//power source. For fritzing diagram, see Github repository 
//https://github.com/nickalanf/Arduino--Projects

//The Serial monitor section is for debugging purposes, or for general interest,
//one once the device is functioning correctly, can be diasabled
//
//Sketch by FIELDING - 8/2/18


#include <Servo.h>

Servo servo;   // Create a servo object to control the servo
int eLDRPin = A0; // Assign pins to the LDR's
int wLDRPin = A1;
int eastLDR = 0; //Create variables to store to LDR readings
int westLDR = 0;
int difference = 0; //Create a variable to compare the two LDR's
int error = 10;  // Variable for is there is a noticable difference between the tow LDR's
int servoSet = 130; //Variable for position of servo - will be different for each device


void setup() {
  servo.attach(9);   //attaches the servo object to PWM pin 9
  Serial.begin(9600); 
}

void loop() {
  eastLDR = analogRead(eLDRPin); //Read the LDR values
  westLDR = analogRead(wLDRPin);

  if (eastLDR < 400 && westLDR < 400) {  //Check to see if there is low light on both LDR's
    while (servoSet <=140 && >=15) {     // if so, send panels back to east for the sunrise
      servoSet ++;
      servo.write(servoSet);
      delay(100);
    }
  }

  difference = eastLDR - westLDR ; //Check the difference 
  if (difference > 10) {          //Send the panel towards the LDR with a higher reading
    if (servoSet <= 140) {
      servoSet ++;
      servo.write(servoSet);
    }
  } else if (difference < -10) {
    if (servoSet >= 15) {
      servoSet --;
      servo.write(servoSet);
    }
  }
  Serial.print(eastLDR);      //Serial monitor can be useful for debugging/setting up
  Serial.print("   -   ");    //Use it to see if your LDR's are noticeably different when
  Serial.print(westLDR);      //They have equal light shining on them, if so, correct with the error value
  Serial.print("   -   ");
  Serial.print(difference);   
  Serial.print("   -   ");
  Serial.print(servoSet);     //Fine tune the servo settings, to maximise swing available
  Serial.print("   -   ");
  Serial.println(".");
  delay(100);
}

Credits

FIELDING

FIELDING

3 projects • 63 followers
Arduino Tinkerer -- Renewable Energy Data Analyst --

Comments