Sunspot (head Mounted Sunblocker)
by Aric Caley in Circuits > Wearables
1709 Views, 3 Favorites, 0 Comments
Sunspot (head Mounted Sunblocker)
When I was kid, in the car with my dad driving, he used to always complain about the sun being in his eyes. So he had this idea of a "sunspot" (this was the 80's and as I remember Sun Spots were frequently in the news), which was a little disk with a suction cup on it so he could stick it to the windshield right where the sun was.
Needless to say it was less than practical given that the car moved frequently so it didnt work without moving it, and also we figured eventually a cop would pull us over and such a device would never pass DOT rules if we tried to manufacture them. The idea died (we did make prototypes though).
Flash forward to today and with modern technology, I have resurrected the sun spot idea! Only this time its mounted on your head and uses light sensors to automatically move the spots to where they need to be so the sun is no longer in your eyes.
Initially, I had planned a 2 axis mechanical system that would move up and down and left to right, driven by no less than a 9 axis positioning chip (accelerometer, gyroscope and magnetometer), a real time clock, and programmed knowledge of your timezone and calculating where the sun should be.
Quickly I realized a much easier way to do it. Simply measure brightness and move the spot towards the brightest detection. Although the former method may be more accurate and faster, the later in fact works.
Supplies
2 LDR detectors.
Arduino pro mini, nano, or any other arduino you have on hand
Proto board
Battery pack
Wires
Micro servo
Hat
Double sided tape
Hot glue
Cardboard
Popsicle stick
Make a Sun Spot
To prototype this I used easily available cardboard. Its free, easy to get, and easy to work with. I just roughly sketched out what I needed for the sun spot itself and the arm it hangs from, this includes a little diagonal to add strength.
Servo Movement
To mount the servo, I simply used a rectangle of cardboard and folded it up and around the servo, using hotglue to hold it in place. This is then glued to a bottom rectangle. This makes a pretty strong holder for the servo that will then be mountable to the hat. I have used this method numerous times before to create cardboard creations with movement.
Create a Light Sensor
The sensor for the sun spot is as simple as it gets. Because we're only going to move on one axis, we only need two LDR sensors. They are separated by a bit of cardboard such that as the sun moves to one side or the other, the light falling on the sensors will be different. This lets us calculate a difference in order to drive the servo motor one way or the other until the sensors have an equal amount of light on them.
Since this is a quick prototype, I have literally created a circuit board from the cardboard. I simply poked holes through the cardboard and inserted the LDRs and the resistors into it, and folding the wires on each other to form the circuit.
The circuit is simple. Just an LDR connected to 5+ volts, and another resistor connected to ground. Where they come together, we wire that to the Arduino for detection of the voltage.
The Brains
For this I used an Arduino Pro Mini, but you can use any arduino you have available. It only uses two analog inputs and one PWM output pin. I've put this onto a proto board and used a handy proto board power unit.
The LDR sensors connect to analog pins 0 and 1, and the servo to pin 6. That's it!
The code for this is also pretty simple. It samples the two LDRs, creating a difference between the readings and then using that to move the servo until the LDR's a close in value. There's a variable to set the minimum variance (ie, the LDRs can be this much appart and it wont do anything). Also, I found that one of my LDRs with full light had a different value than the other one (by as much as 20) so I created a calibration step on startup that measures the average difference.
// include Servo library #include <Servo.h> // horizontal servo Servo horizontal; int servoh = 90; int servohLimitHigh = 180; int servohLimitLow = 0; // LDR pin connections int ldrTR = 0; // LDR top right int ldrTL = 1; // LDR top left int avgdev = 0; void setup() { int calloop = 100; int sampletotal = 0; int tr, tl, l; Serial.begin(9600); // servo connections horizontal.attach(6); // move servos horizontal.write(90); // Calibrate LDRs for (l = 0;l<calloop;l++) { tr = analogRead(ldrTR); // top right tl = analogRead(ldrTL); // top left sampletotal += tr-tl; delay(10); } avgdev = sampletotal / 1000; Serial.print(avgdev); delay(3000); } void loop() { int tr = analogRead(ldrTR); // top right int tl = analogRead(ldrTL); // top left if (avgdev < 0) tl += avgdev; else tr+=avgdev; int dtime = 0; // change for debugging only int tol = 5; int avt = (tl + tr) / 2; // average value top int dhoriz = tl -tr; Serial.print(avgdev); Serial.print(" "); Serial.print(tl); Serial.print(" "); Serial.print(tr); Serial.print(" "); Serial.print(" "); Serial.print(tol); Serial.print(" "); Serial.print(servoh); Serial.println(" "); if (-1 * tol > dhoriz || dhoriz > tol) { if (tl > tr) { servoh = --servoh; if (servoh < servohLimitLow) { servoh = servohLimitLow; } } else if (tl < tr) { servoh = ++servoh; if (servoh > servohLimitHigh) { servoh = servohLimitHigh; } } else if (tl = tr) { // nothing } horizontal.write(servoh); } delay(dtime); }
Put It All Together
A trip to the family art supply room provided an orange popsicle stick which I then glued to the servo. This was just the right length to hang the sun spot from.
To complete the sun spot, I glued the sensor onto it. Finally, glue the sensor to the end of the popsicle stick.
With all the wires connected, I finally used some double sided tape (I didn't want to ruin the hat with hot glue) to attach the servo, the proto board and the battery pack.
Test!
Video of test using light from phone: https://youtu.be/3jKSOyoXYCM