mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
121 lines
9.7 KiB
HTML
121 lines
9.7 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"/>
|
|
<title>ArduinoLibs: Alarm Clock</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body onload='searchBox.OnSelectItem(0);'>
|
|
<!-- Generated by Doxygen 1.7.4 -->
|
|
<script type="text/javascript"><!--
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
--></script>
|
|
<div id="top">
|
|
<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>
|
|
<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 id="searchli">
|
|
<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>
|
|
</div>
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Alarm Clock </div> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<div class="textblock"><h2><a class="anchor" id="clock_features"></a>
|
|
Features</h2>
|
|
<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. </li>
|
|
<li>Configurable alarm timeout between 2 and 10 seconds. </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>
|
|
</ul>
|
|
<h2><a class="anchor" id="clock_main_circuit"></a>
|
|
Main circuit</h2>
|
|
<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, and a piezo buzzer for the alarm:</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 and piezo buzzer 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>
|
|
<h2><a class="anchor" id="clock_arduino_board"></a>
|
|
Arduino board</h2>
|
|
<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>
|
|
<h2><a class="anchor" id="clock_ds3232"></a>
|
|
Using DS3232 instead of DS1307</h2>
|
|
<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"><pre class="fragment"><span class="keyword">typedef</span> <a class="code" href="classDS3232RTC.html" title="Communicates with a DS3232 realtime clock chip via I2C.">DS3232RTC</a> Clock;
|
|
</pre></div><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>
|
|
</div></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></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>
|
|
|
|
<hr class="footer"/><address class="footer"><small>Generated on Wed May 30 2012 15:44:34 for ArduinoLibs by 
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
|
|
</body>
|
|
</html>
|