Solar Golf Ball Washer
This was the final project for my Graphics, CAD, and Design class where I learned to use Solidworks and Arduino. This automatic golf ball washer uses a solar panel that follows the sun to recharge.
Final Sketch
CAD Assembly
Functioning Prototype
For this project, I started by creating multiple rough sketches of my idea to help myself visualize what I want the final product to look like. I then modeled all the components in an assembly in Solidworks to confirm all the dimensions. Lastly, I 3D printed the outer shell of the prototype and was able to assemble a working prototype.
Arduino C++ Code
#include <VarSpeedServo.h>
VarSpeedServo xAxis;
VarSpeedServo zAxis;
int xAngle;
int zAngle;
int TRVal;
int TLVal;
int BLVal;
int BRVal;
int avgT;
int avgB;
int avgL;
int avgR;
int xDiff;
int zDiff;
//Define phototransistor pins
int const TR = A0;
int const TL = A1;
int const BL = A2;
int const BR = A3;
void setup() {
xAxis.attach(10);
zAxis.attach(11);
xAngle = 89; //Initialize motors at center
zAngle = 89;
Serial.begin(9600);
delay(1000);
}
void loop() {
TRVal = analogRead(TR);
TLVal = analogRead(TL);
BLVal = analogRead(BL);
BRVal = analogRead(BR);
avgT = (TLVal + TRVal)/2;
avgB = (BLVal + BRVal)/2;
avgL = (TLVal + BLVal)/2;
avgR = (TRVal + BRVal)/2;
xDiff = avgT - avgB; //Determine brightness difference between top and bottom
Serial.print("xDiff: ");
Serial.println(xDiff);
zDiff = avgL - avgR; //Determine brightness difference between left and right
Serial.print("zDiff: ");
Serial.println(zDiff);
Serial.print("X Angle: ");
Serial.println(xAngle);
Serial.print("Z Angle: ");
Serial.println(zAngle);
//Keep angle within bounds
if (xAngle < 0) {
xAngle = 0;
}
if (xAngle > 179) {
xAngle = 179;
}
if (zAngle < 0) {
zAngle = 0;
}
if (zAngle > 179) {
zAngle = 179;
}
//Handle angle increment when array orientation flips
if (xDiff > 5 && 90 <= xAngle <= 179) {
xAngle--;
xAxis.write(xAngle);
}
else if (xDiff < -5 && 90 <= xAngle <= 179) {
xAngle++;
xAxis.write(xAngle);
}
else if (xDiff > 5 && 0 <= xAngle <= 89) {
xAngle++;
xAxis.write(xAngle);
}
else if (xDiff < -5 && 0 <= xAngle <= 89) {
xAngle--;
xAxis.write(xAngle);
}
if (zDiff > 5 && 90 <= xAngle <= 179) {
zAngle--;
zAxis.write(zAngle);
}
else if (zDiff < -5 && 90 <= xAngle <= 179) {
zAngle++;
zAxis.write(zAngle);
}
else if (zDiff > 5 && 0 <= xAngle <= 89) {
zAngle++;
zAxis.write(zAngle);
}
else if (zDiff < -5 && 0 <= xAngle <= 89) {
zAngle--;
zAxis.write(zAngle);
}
}