loading

Most technology Instructables are fun to construct, and often easy to build. This is one that shares those features, but also solves a practical problem we had.

To prevent fading of furniture, carpet, and the wood flooring in our foyer, my spouse and I installed one-way blackout shades. However, after installation and use, a problem arose. The air in the foyer began to have a slightly “musty” odor as no sunlight was coming in. My solution was to build a direct sunlight detector, allowing us to close the shades only when the buzzer went off. On overcast days the shades would stay open, as the direct sunlight would not set the alarm off (we live in the Eastern US, so overcast days are not uncommon). It also meant that we could leave the shades open until we heard the alarm on clear days. The result – all the “mustiness” is now gone and as a bonus the foyer is less “gloomy”. A quick, inexpensive and winning solution on all counts. The video shows the alarm "in action".

Like many readers and posters here, I really like LEDs and so have added one to this project. However, it is optional and not a requirement.

Step 1: What's Needed

Required Items

- 95DB 3-24v High-decibel Electronic Buzzer

- An Experimental Prototype Board

- A Half-Size, 400 tie points, Breadboard

- An Arduino UNO R3

- A 10k Resistor (1/4 to 1 Watt)

- A photoresistor, almost any will do (e.g., 112582, 5516, 5528, 5537, 5539, or 5549)

Optional Items

- Two Pieces Heat Shrink Wire Wrap (Size 2.5 x 40mm)

- An LED (any color in 3mm or 5mm size)

- A 2k Resistor (1/4 to 1 Watt)

The optional items are just that. While I used shrink wrap to cover the solder joints to the buzzer, black electrician’s tape should work just as well. I added the LED so that in addition to the sound of the alarm it would blink on and off when direct sunlight was detected. However, since the high-decibel alarm goes off when this is the case, the LED and its 2k resistor can be left off without any lose in detection function.

Step 2: Connecting the Arduino UNO and Half-Size Breadboard to the Experimental Platform.

See my earlier Instructable, “Experimental Platform For the Arduino UNO R3 - How To Prepare It For Use“, at https://www.instructables.com/id/Experimental-Platform-for-the-Arduino-UNO-R3-How-t/ to see how this can be easily done.

Step 3: Alarm Wires

I removed the plastic cover on one side of a red Dupont male-to-male cable and soldered the pin to the red lead from the alarm. I did the same thing with a dark blue Dupont cable and soldered it to the black wire from the alarm. I covered both solder joints with heat shrink wire wrap (see 1st photograph), although as noted above black electrician’s tape will work as well. I connected the red wire to the breadboard and then, using an additional jumper cable, connected that wire to digital socket two of the Arduino Uno

That is,

- Red wire from alarm to digital socket 2 on UNO

I connected the black wire from the alarm to the ground rail on the breadboard which went to a GND pin on the UNO.

That is,

- Black wire from alarm to GND socket on UNO

Step 4: Adding the Optional LED

The positive side of the LED is connected to digital socket 12 of the Arduino UNO, and the negative side is connected through a 2k resistor to a UNO GND socket.

I do not like excessively bright, to me, LEDs so I used a 2k resistor here. If you do not mind, or you would like, a brighter LED you may want to use a 330-560 ohm resistor instead of the 2k one I used.

That is,

- Long wire on LED to UNO digital socket 12

- Short wire on LED, going through a 2k resistor, to UNO GND socket.

Step 5: Adding the Photoresistor

I used a T5516, but as noted above almost any photosensitive resistor will do. One side of the photoresistor goes to 5v on the Arduino. The other side goes through a 10k resistor to a GND socket on the Arduino. I connected a wire from GND on the Arduino UNO to the negative rail on the breadboard and used it for all my ground connections. The 10k resistor and photoresistor formed a voltage divider. I took the location on the breadboard where the photoresitor connected to one side of the 10k resistor and connected it to analog socket A1 to be able to obtain photoresistor measurements of the light.

That is,

- One side of the photoresistor to 5v on the UNO

- The other side of the photoresistor connects on the breadboard to a 10k resistor and then that resistor goes to ground.

- Lastly, the location where the photoresistor and 10k resistor join was connected to UNO analog socket A1.

Interesting discussions, about photoresistors can be found in the Instructables, "How to use a Photoresistor (or photocell) - Arduino Tutorial" by codebender_cc and "Photoresistors" by OlaC.

Step 6: The Sketch

Enter the sketch below into the Arduino IDE, and run it.

int photoresistorPin = A1; // Photoresistor pin connection

int ledPin = 13; // LED pin connection

int dacValue = 0; // Store the value read from the sensor

int buzzerPin = 2; // Buzzer pin connection

unsigned int x=65535; // Stores mapped dac value (ranges from 0 - 100%)

void setup() {

pinMode(ledPin, OUTPUT);

pinMode(buzzerPin, OUTPUT);

pinMode(photoresistorPin, INPUT);

}

void loop() {

dacValue = analogRead(photoresistorPin);

x = map(dacValue, 0, 1023, 0, 65000);

x = round(x/650.0); // To obtain a range from 0 to 100

Serial.println(x);

if(x >= 95) {

digitalWrite(buzzerPin, HIGH);

digitalWrite(ledPin, HIGH);

delay(250);

digitalWrite(ledPin, LOW);

delay(100);

}

if(x< 94) digitalWrite(buzzerPin, LOW);

}

Step 7: Afterwards

The last picture shows the assembled detection alarm systems in the foyer from somewhat of a distance. The first photograph shows an assembled system close-up. I powered my UNO using a 9v DC "wall wart". However, power can be provided to the UNO in a variety of other ways, including battery if you need a portable sunlight detector. Depending on where you place this alarm, and the photoresistor you use, you may want to change the value of 95 used in the sketch. This value represents the threshold, out of a total of 100, at which the alarm goes off.

That is all there is to it; it is as simple as it seems. If you leave off the LED and associated resistor, not really required to detect direct sunlight, the alarm is even easier to construct.

Congratulations, if you followed the steps above you now have your own sunlight detection alarm.

If you would like to contact me with any questions or for additional information, or to expand my knowledge in the area presented, I can be reached at transiintbox@gmail.com. (please replace the second 'i' with an 'e' to contact me.

<p>awesome application and well instructed :)</p>
<p>Dear Throne85,</p><p>Thank you for the kind comment. </p><p>The very best. </p>
<p>excellent</p>
<p>Thank you for your generous comment.</p><p>The very best. </p>
<p>Nice project! I'm just curious about these two lines:</p><p><em> x = map(dacValue, 0, 1023, 0, 65000);</em></p><p><em> x = round(x/650.0); // To obtain a range from 0 to 100</em></p><p><em>Why not just use a single map function with 0 to 100 as the target values?</em></p><p><em style="">x = map(dacValue, 0, 1023, 0, 100);</em></p><p><em style="">Thanks!</em></p>
<p>Thank you for your interest and question.</p><p>You can map the result of the analogRead() to 0-100, and considering how I use the results, that would likely work. However, to quote &ldquo;arduino.cc&rdquo;, &ldquo;The map() function uses integer math so will not generate fractions, when the math might indicate that it should do so. Fractional remainders are truncated, and are not <em>rounded</em> or averaged.&rdquo;</p><p>The very best.</p>
<p>awesome application and well instructed :)</p>
<p>Thank you for taking the time to post your kind comments. They are appreciated.</p><p>The very best.</p>
<p>Interesting reason for building this project. Now that you have it proto-typed, why don't you incoropate it into some motor driven shades and have your circuit control everything? Just a suggestion. Thumbs Up.</p>
<p>Thank you for taking the time to send this message and the kindness of your note. It is appreciated.</p><p>We had considered this extension to the project but have not yet found a way to hide the motor and wires.</p><p>The very best.</p>
<p>Have you looked at planetary gear motors that would easily go on the inside of a blind sleeve setup and the only thing you would have to control would be the distance it would travel/run. Maybe a stepper motor configuration with a planetary geared motor in the sleeve then you can count the steps for any position and make presets. IDK, just thinking out loud...to my self. </p>
<p>Thank you for the follow-up.</p><p>A planetary gear motor would work at the voltages we would use,<br>and provide the torque required at the speed needed. Unfortunately, although possibly reducing the footprint of the needed components, it would not eliminate the need to hide motors and wires.</p><p>Our shades are not the conventional &ldquo;Venetian Blinds&rdquo; but shades whose height is controlled by a chain loop with plastic stops for height control. With four shades across the entrance, hiding is difficult but would be required. The &ldquo;cornice&rdquo; above these shades is quite small being only large enough to conceal the shades when not in use.</p><p>However, we would be pleased to consider your suggestions in more detail, and perhaps we will find a solution to the &ldquo;hiding&rdquo; issue. If so, we would be happy to post it as a follow-up Instructable.</p><p>Thank you again for your comment, and the very best.</p><p>P.S. I have now included a video in this Instructable to show the alarm in use.</p>

About This Instructable

3,895views

81favorites

License:

More by R Jordan Kreindler:Arduino Stepper Drivers Tutorial-2/2 Arduino Stepper Drivers Tutorial-1/2 DC Motors Tutorial-3/3: Steppers 
Add instructable to: