Stupid Pet Trick

Without a decent idea and having wasted a lot of time messing around with a handful of different motors, I decided to go on a little getaway to Yas Mall with Ross. As we stopped by Daiso to pick up some bubble solution, I spotted this little solar-panel-powered-plastic-plant (SPPPP) with leaves that would bob up and down if given a strong enough light source. I figured then and there that I could perhaps create some sort mechanical plant that would simulate the behavior of the actual plant. The sunflower and it’s tendency to follow the sun throughout the day seemed like as good a choice as any.

I began by mapping out the algorithm and writing it into code. The logic behind my device was basically just calculating the difference between the values from the two LDRs placed on two opposing ends of my panel and tilting the panel towards either end based on the value and the sign of the difference.

My code:

#include <Servo.h>

Servo myServo;

const int servoPin = 5;

const int photoResistor1 = A0;

const int photoResistor2 = A1;

int prReading1;

int prReading2;

int readingDiff;

int servoPos = 90;

void setup() {

// put your setup code here, to run once:

myServo.attach(servoPin);

Serial.begin(9600);

}

void loop() {

// put your main code here, to run repeatedly:

prReading1 = (analogRead(photoResistor1) + 79);

Serial.print(prReading1);

Serial.print(”    “);

prReading2 = analogRead(photoResistor2);

Serial.println(prReading2);

readingDiff = prReading1 – prReading2;

 

// if light is very dim, return to starting position.

if (prReading1 < 30 && prReading2 < 30){

servoPos = 180;

myServo.write(servoPos);

}

// when reader1 > reader2

if (readingDiff > 10){

if (servoPos <= 180){

servoPos++;

myServo.write(servoPos);

}

}

// when reader1 < reader2

if (readingDiff < -10){

if (servoPos >= 0){

servoPos–;

myServo.write(servoPos);

}

}

}

With the code completed, I built a prototype out of cardboard (stand, panel, servo arm) and wire (pivot, axel). The design was sound until when I had to figure out how to replicate it with acrylic/wood. The pivot made out of wire no longer worked as it did with cardboard since acrylic is a much harder and solid material that simply did not allow the kind of penetration that cardboard did. I ended up redesigning the pivot/axel by laser cutting out holes in the panel and stand and installing a bolt/screw as the axel.

After putting the device together, I realized that the white acrylic panels coupled with the metallic bolt/screw were actually very aesthetically pleasing. Instead of covering it with sunflower decal, I decided to just leave it as it is. A practical implementation for this device could be to enable solar panels to turn and face the sun throughout the entire day, maximizing the amount of energy it could harvest.

The following video is a demonstration of the device in action:

Leave a Reply

Your email address will not be published. Required fields are marked *