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,

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()

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

Serial.print("Left Reading = ");
Serial.print("Right Reading = ");

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


Long Time No See!

Hello everyone!

If you’re still following this blog, you’ve noticed that I haven’t posted in over a year.  It’s time to give a quick update.

I’m about the graduate college!  And we know what that means, more time to update the blog!  What’s in store for me in the future?  I’m about to start a major new chapter in my life.  I’m moving across the country to the wonderful central coast of California, home to some of the most innovative and new developments in technology.  I’ll be working a typical 9-5 job, and I do plan on spending some afternoon working on my projects.

Some of the projects I’ve lost interested in, but I’ve also been thinking of a lot of new projects as well.  I’ve recently been working on a solar powered small airplane, which didn’t quite end well.  But I think I can build on that idea.  Possibly with a solar powered quadcopter, or something of that sort.  I haven’t had much time to work on my computer.  I turned it on today for the first time in  5 months.  Some issues popped up, it seems like one of the RAM sticks died.  Removing the stick seemed to fix all the problems, though I’m now running on 6 gigs of ram.

The next couple weeks will be hectic for me.  I have to finish my last exams, graduate, and move across country, but expect to see some more posts in the following months!

The DIY World is Changing

Picture courtesy of

A friend showed me a wonderful article on the ieee website revealing the history behind the Arduino.

You can read the article Here.

It’s wonderful to see the professional world of ieee promoting the Arduino.  For the longest time, it’s be regarded as something as unprofessional or something just for “blog cred”.  Hopefully we can see a major change in way people view open-source projects in the near future.

Coding in time lapse

Wow, that was fast!

All the Colors of the Rainbow!

Good things happen to those who have time!

Finals are over and its off to work! But until work starts on Monday, I have some time to work on the computer a bit. I won’t have personal internet service until Monday night, so I spend a good portion of the day working on the Bouncing Ball grapher. I rewrote it and used a While loop to repeatedly calculate each bounce. One thing I rarely do is write out my logic on paper first, but I decided to try it and it really did help. I might scan the paper and post it here just to show you how I did my notes. Looking at it now, Its pretty comical, but it helped a lot.

Here’s the revised code,

import numpy as np
import matplotlib.pyplot as plt
import math

h0 = input("Initial Height ")
e = input("Coefficient of Restitution ")
g = 9.806 #gravity at system

Tb = math.sqrt(2.0*h0/g)
Vf = math.sqrt(2.0*h0*g)
t = np.linspace(0,Tb,100)
h1 = -.5*g*t*t+h0
h2 = h1
Tstart = 0


while (np.amax(h2) > .1*h0):
  V0 = e * Vf
  Tstart = Tstart + Tb
  Tb = 2.0*V0/g
  t = np.linspace(Tstart, Tstart + Tb, 100)
  h2 = -.5*g*(t-Tstart)*(t-Tstart)+V0*(t-Tstart)
  Vf = math.sqrt(2.0*np.amax(h2)*g)
  h1 = h2

I haven’t commented everything yet. Maybe I’ll get around to it later.

Here’s an example of an output,
ooooo pretty colors

That’s with an initial height of 16 and a COE of .74. The program compares the height of the last bounce with the initial height to determine when to stop. If the bounce gets small enough, the program will terminate and show the final graph.

Python Progress

My first python project is getting close to done.

I wanted to start with something quick and easy.  Something that would show me the syntax of the language, but not complicated enough to make me spend hours of research trying to figure it out.

What I did was write a script that graphs the height of a bouncing ball over time.   What the program really does, is ask the user to input the initial height and COR of the ball, then it just runs through some easy calculations and shows a graph.  I’m not quite done though, right now I have it graphing only the first two bounces.  What I want to do is write it as a loop and terminate when the height of the ball doesn’t reach higher than a certain percentage of the initial height.

Here’s the code so far:

import numpy as np
import matplotlib.pyplot as plt
import math

#h1 = 10       #input the initial height
h1 = input("Initial Height ")
e = input("Coefficient of Restitution ")
g = 9.806                     #gravety at system

#NOTE: Somehow turn into a loop
v1 = math.sqrt(g*h1*2) 
     #instant velocity before impact, from energy equation
v2 = v1*e                  #instant velocity after impact,
tlim = math.sqrt(2.0*h1/g) #time of impact, setting h = 0
t = np.linspace(0,tlim,100)#array of time from 0 to impact
h = -1/2.0*g*(t*t)+h1      #h from 0 to impact
t2 = np.linspace(tlim,(v2*2/g+tlim),100)
                 #array of time from 1st impact to 2nd
h2 = -(1/2.0)*g*((t2-tlim)*(t2-tlim))+v2*(t2-tlim)           
                 #equation for h from 1st impact to 2nd


And here’s the output:

Initial Height = 10
Coefficient of Restitution = .8

The output of 10 and .8, also includes pretty colors

For a bit of fun, I set gravity as a changeable parameter.  So if you wanted to see how the ball would bounce in microgravity, you could set the value of g to .000001 (1e-6) and see what happens.

Solar Tracker Finished! – somewhat


Add one to the list.

Summer classes take up a LOT of time…  Man, I finished the Solar Tracker for now, but I haven’t even had time to get to the garage and use the camera to make a video showing it working.  I will eventually, I promise.

While classes have my tied up, there is one thing I think I could easily manage and that’s learning a new programming language.  I’ve recently been looking into a programming language that I can use as an alternative to MATLAB and possibly LabVIEW.  What I found is scipy.

Scipy is a package add-on to Python, and can be used for simple or complex calculations.  I still need to dig into it more, but I’m seeing a lot of potential.

Concerning the things currently on the list, there’s a lot of stuff on there that requires more funding.  Until then, a lot of those will be put off for later.


Pretty soon I think I’m going to create a how-to guide for installing scipy and all of its dependencies.  I did this in Windows 7 by the way.


The terminology page is slowly growing!  Surprisingly, its a very tedious task.

Also, I’m still looking for a personal banner to put in the header.  If someone is skilled with image editing and would like to make one for the page, let me know.  You’re help is greatly appreciated.


Hello all,

As I hope you noticed, we are no longer on blogspot.  Through a few hours of research, I’ve come to the conclusion that wordpress would be better host for the list.  It is a bit more open ended and allows me to edit a few more things.  For example, I now have a twitter feed on the far right, along with a few more pages on the top.  The built in templates are a bit nicer as well.  I think the colors are a bit more soothing.

If you navigate through the pages, you’ll come across a “Terminology” page.  I gotten a few complaints about the technical terms used and a few people are having a hard time following along.  The terminology page should help explain a few things better.  Also you’ll find an “About Me” page.  I’ve been rather hesitant about giving out my personal information, but due to the lack of comments, I thought it would be better to open up a bit more.  The page explains some background about me along with why I started the blog.

I’d also like to mention that I am completely open to comments and questions.  In fact, I encourage them.  It lets me know that this is helping a few people other than myself.  So whenever you get a chance, leave a comment below.  Or if you want to be more private, feel free to email me.

See you soon!