Category Archives: solar

Solar Tracker Code

As requested, here is the .c Arduino code to the Solar Tracker.  I haven’t uploaded it and tested it in a while, but from what I remember, the program works well for a single axis rotation.  With indoor lighting, it should work fine, but outside the Sun light might be too bright and max out the reading from the photoresistors.

Stephane Juan made found a nice solution to this problem.  He placed tubes around the photoresistors to cast a shadow over the resistors when the sun isn’t directly above.  The angle of the shadow is determined by the height of the tubes.  Here’s a picture of his setup, http://stephane.jouin.free.fr/suiveur_solaire.JPG

And without further adieu, here’s the Solar Tracker Code

/*
Solar Tracker
This program controls a servo to allow 
solar cells to always face the source of light
Created 1/18/11
Ian Bohannon
Copyright 2011
*/

#include <Servo.h>

int ServoOut = 9;
int photoPinLeft = 0;
int photoPinRight = 5;
int LeftReading;
int RightReading;
int pos;
int tolerance = 5; /* +/- the total difference 
between the two photoresistors. You can test 
this by covering both the resistors in total darkness, 
and note the difference between the two readings. */

Servo myservo;

void setup()
{
myservo.attach(ServoOut);
Serial.begin(9600);
}

void loop()
{
LeftReading = analogRead(photoPinLeft);
RightReading = analogRead(photoPinRight);

Serial.print("Left Reading = ");
Serial.println(LeftReading);
Serial.print("Right Reading = ");
Serial.println(RightReading);

if(LeftReading > RightReading + tolerance)
{
pos = 58;
}
else if(LeftReading + tolerance < RightReading)
{
pos = 52;
}
else
{
pos = 55;
}

myservo.write(pos);
delay(120);
}
Advertisements

Update

For the few of you who read this,
I finished the solar tracker!  I’m busy at the moment, but I’ll eventually get a video showing you what it can do.  Until then, you’ll just have to wait.

Furthermore, I’m also planning on replacing my Arch partition with Xubuntu.  I’m also most likely going to reorganize my computer boot sequence as well.  I currently have my boot partition doing nothing but booting, which seems kinda silly.

On the hardware side, I just upgraded my RAM from the 2×1 Gb Crucial 1033 Mhz to a 2×2 Gb Corsair 1600 Mhz.  So far I’ve noticed a slight improvement in Windows (which is 64bit) and I haven’t tried it in Arch yet.

Also, if you haven’t already, check out This Week in Linux with Jordan Keyes.  He recently lost his adsense account due to some strange DDoS/Misuse  and showing all of his videos either through Blip.tv or through his website.  I highly suggest everyone watch his videos, he’s a wealth of knowledge!