mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
149 lines
12 KiB
HTML
149 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.6"/>
|
|
<title>ArduinoLibs: Alarm Clock</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() { searchBox.OnSelectItem(0); });
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">ArduinoLibs
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.6 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
<li>
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Pages</a></div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Alarm Clock </div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><h1><a class="anchor" id="clock_features"></a>
|
|
Features</h1>
|
|
<p>The alarm clock described on this page is a large example application that uses many of the classes in the provided libraries: <a class="el" href="classLCD.html" title="Enhanced library for Freetronics 16x2 LCD shields. ">LCD</a>, <a class="el" href="classForm.html" title="Manager for a form containing data input/output fields. ">Form</a>, <a class="el" href="classField.html" title="Manages a single data input/output field within a Form. ">Field</a>, <a class="el" href="classSoftI2C.html" title="Bit-banged implementation of an I2C master. ">SoftI2C</a>, <a class="el" href="classDS1307RTC.html" title="Communicates with a DS1307 realtime clock chip via I2C. ">DS1307RTC</a> (or <a class="el" href="classDS3232RTC.html" title="Communicates with a DS3232 realtime clock chip via I2C. ">DS3232RTC</a>), <a class="el" href="classMelody.html" title="Plays a melody on a digital output pin using tone(). ">Melody</a> and <a class="el" href="group__power__save.html">PowerSave</a>. The clock has the following features:</p>
|
|
<ul>
|
|
<li>Displays both the time and date. </li>
|
|
<li>12 hour and 24 hour time display modes. </li>
|
|
<li>Up to 4 configurable alarm times, plus a snooze alarm. </li>
|
|
<li>Three alarm sounds to choose from, plus an option to use a radio alarm. </li>
|
|
<li>Configurable alarm timeout between 2 and 10 seconds. </li>
|
|
<li>Alarms can be configured to only sound on Monday to Friday or on Saturday and Sunday. </li>
|
|
<li>Single button to activate the back light and/or stop the alarm. </li>
|
|
<li>Up, down, left, and right buttons to change clock settings. </li>
|
|
<li>MOSFET that controls the power to a separate radio circuit.</li>
|
|
</ul>
|
|
<h1><a class="anchor" id="clock_main_circuit"></a>
|
|
Main circuit</h1>
|
|
<p>The main clock circuit consists of an Arduino Uno compatible board, a 16x2 <a class="el" href="classLCD.html" title="Enhanced library for Freetronics 16x2 LCD shields. ">LCD</a> module, a realtime clock chip, a piezo buzzer for the alarm, and a MOSFET for controlling the radio:</p>
|
|
<div class="image">
|
|
<img src="alarm_circuit.png" alt="alarm_circuit.png"/>
|
|
</div>
|
|
<p>Some of the components can be purchased ready-made as the <a href="http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide">Freetronics 16x2 LCD Shield</a> and the <a href="http://www.sparkfun.com/products/99">SparkFun Realtime Clock Module</a>. I used the ready-made realtime clock module, but made my own equivalent to the <a class="el" href="classLCD.html" title="Enhanced library for Freetronics 16x2 LCD shields. ">LCD</a> shield from parts to aid in spacing out the <a class="el" href="classLCD.html" title="Enhanced library for Freetronics 16x2 LCD shields. ">LCD</a> and pushbuttons on the exterior of the box. The value of the 33R resistor may need to be adjusted for different types of back light LED's. See <a class="el" href="alarm_clock.html#clock_ds3232">below</a> for information on using a DS3232-based clock module instead of a DS1307-based module.</p>
|
|
<p>The whole circuit is built on a prototyping shield, with ribbon cables connecting to the <a class="el" href="classLCD.html" title="Enhanced library for Freetronics 16x2 LCD shields. ">LCD</a>. The Stop Alarm button, piezo buzzer, and radio controller are not shown in this picture and some of the components are soldered to the bottom of the shield:</p>
|
|
<div class="image">
|
|
<img src="clock_shield.jpg" alt="clock_shield.jpg"/>
|
|
</div>
|
|
<p>The clock module is based on the DS1307 chip and has an on-board coin battery to keep the time and date ticking over even if the main circuit loses power. The chip is I2C-based and has an auxillary SQW output that can be configured to provide a 1 Hz squarewave signal. This signal is used by the software running on the Arduino to detect when a new time or date is available for display on the <a class="el" href="classLCD.html" title="Enhanced library for Freetronics 16x2 LCD shields. ">LCD</a>. The <a class="el" href="classDS1307RTC.html" title="Communicates with a DS1307 realtime clock chip via I2C. ">DS1307RTC</a> class takes care of the details of talking to the chip via I2C.</p>
|
|
<h1><a class="anchor" id="clock_arduino_board"></a>
|
|
Arduino board</h1>
|
|
<p>To keep power consumption low, say for being powered by batteries, we don't need a full Arduino Uno or similar board. The USB interface is unnecessary, as is the on-board power supply if there is an external source of 5 volt power. We also don't want the power and D13 status LED's to be draining power. Therefore, a cut-down version of the Arduino is recommended. We used the <a href="http://www.freetronics.com/collections/arduino/products/kitten">KitTen</a> kit from <a href="http://www.freetronics.com/">Freetronics</a>, and didn't solder up anything that wasn't strictly necessary. A <a href="http://www.freetronics.com/ftdi-cable">5v FTDI USB-to-Serial cable</a> is necessary for programming. Similar minimalistic built-it-yourself Arduino designs should also work.</p>
|
|
<div class="image">
|
|
<img src="kitten_minimal.jpg" alt="kitten_minimal.jpg"/>
|
|
</div>
|
|
<h1><a class="anchor" id="clock_radio"></a>
|
|
Controlling a radio</h1>
|
|
<p>The MOSFET connected to D11 can be used to control the power supply to a separate radio circuit so that the radio can be used as an alarm. In the following circuit, RadioV+ is the radio's power supply voltage (which may be the Arduino's 5V supply if the radio can run off 5V):</p>
|
|
<div class="image">
|
|
<img src="radio_controller.png" alt="radio_controller.png"/>
|
|
</div>
|
|
<p>The output of the MOSFET can be used to control almost any kind of circuit; for example an extremely loud mechanical alarm bell. It doesn't have to be a radio. A 2N7000 or equivalent MOSFET is suitable for light loads up to 200mA. For larger currents, a higher-rated MOSFET should be used instead.</p>
|
|
<p>Double-tapping the Stop Alarm button will turn the radio on. Single-tapping the Stop Alarm button will turn the radio off. A settings field can also be used to turn the radio on and off.</p>
|
|
<h1><a class="anchor" id="clock_ds3232"></a>
|
|
Using DS3232 instead of DS1307</h1>
|
|
<p>For clock modules based on the DS3232 chip, such as the <a href="http://www.freetronics.com/products/real-time-clock-rtc-module">Freetronics Real Time Clock Module</a>, change the <code>Clock</code> typedef in <code>Clock.h</code> to the following:</p>
|
|
<div class="fragment"><div class="line"><span class="keyword">typedef</span> <a class="code" href="classDS3232RTC.html">DS3232RTC</a> Clock;</div>
|
|
</div><!-- fragment --><p>The pads on the Freetronics module should be connected to the Arduino as follows:</p>
|
|
<ul>
|
|
<li>VCC and GND connected to 5V and GND on the Arduino. </li>
|
|
<li>SQI connected to A3. </li>
|
|
<li>SDA connected to A4. </li>
|
|
<li>SCL connected to A5. </li>
|
|
<li>BAT, 32K, and RST left unconnected.</li>
|
|
</ul>
|
|
<h1><a class="anchor" id="clock_completed"></a>
|
|
Completed Clock</h1>
|
|
<p>The following picture shows the completed clock prototype, built into a UB1 jiffy box with the radio. Being the prototype, it is a little rough and ready, but rugged enough to take a pounding each morning as a bedside alarm clock:</p>
|
|
<div class="image">
|
|
<img src="alarm_clock.jpg" alt="alarm_clock.jpg"/>
|
|
</div>
|
|
</div></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Sun Mar 22 2015 15:54:26 for ArduinoLibs by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.6
|
|
</small></address>
|
|
</body>
|
|
</html>
|