You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
6.4 KiB
148 lines
6.4 KiB
3 years ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.17"/>
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
|
<title>Bounce2: bounce_basic.ino</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/searchdata.js"></script>
|
||
|
<script type="text/javascript" src="search/search.js"></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 id="projectalign" style="padding-left: 0.5em;">
|
||
|
<div id="projectname">Bounce2
|
||
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<!-- end header part -->
|
||
|
<!-- Generated by Doxygen 1.8.17 -->
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||
|
/* @license-end */
|
||
|
</script>
|
||
|
<script type="text/javascript" src="menudata.js"></script>
|
||
|
<script type="text/javascript" src="menu.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
$(function() {
|
||
|
initMenu('',true,false,'search.php','Search');
|
||
|
$(document).ready(function() { init_search(); });
|
||
|
});
|
||
|
/* @license-end */</script>
|
||
|
<div id="main-nav"></div>
|
||
|
</div><!-- top -->
|
||
|
<!-- window showing the filter options -->
|
||
|
<div id="MSearchSelectWindow"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||
|
</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 class="header">
|
||
|
<div class="headertitle">
|
||
|
<div class="title">bounce_basic.ino</div> </div>
|
||
|
</div><!--header-->
|
||
|
<div class="contents">
|
||
|
<p>Basic example of the <a class="el" href="class_bounce.html" title="The Debouncer:Bounce class. Links the Deboucing class to a hardware pin.">Bounce</a> class.</p>
|
||
|
<div class="fragment"><div class="line"> </div>
|
||
|
<div class="line">/*</div>
|
||
|
<div class="line"> DESCRIPTION</div>
|
||
|
<div class="line"> ====================</div>
|
||
|
<div class="line"> Simple example of the Bounce library that switches a LED when</div>
|
||
|
<div class="line"> a state change (from HIGH to LOW) is triggered (for example when a button is pressed).</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> Set BOUNCE_PIN to the pin attached to the input (a button for example).</div>
|
||
|
<div class="line"> Set LED_PIN to the pin attached to a LED.</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">*/</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">// WE WILL attach() THE Bounce INSTANCE TO THE FOLLOWING PIN IN setup()</div>
|
||
|
<div class="line">#define BOUNCE_PIN 2</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">// DEFINE THE PIN FOR THE LED :</div>
|
||
|
<div class="line">// 1) SOME BOARDS HAVE A DEFAULT LED (LED_BUILTIN)</div>
|
||
|
<div class="line">#define LED_PIN LED_BUILTIN</div>
|
||
|
<div class="line">// 2) OTHERWISE SET YOUR OWN PIN</div>
|
||
|
<div class="line">// #define LED_PIN 13</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">// Include the Bounce2 library found here :</div>
|
||
|
<div class="line">// https://github.com/thomasfredericks/Bounce2</div>
|
||
|
<div class="line">#include <Bounce2.h></div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">// INSTANTIATE A Bounce OBJECT</div>
|
||
|
<div class="line">Bounce bounce = Bounce();</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">// SET A VARIABLE TO STORE THE LED STATE</div>
|
||
|
<div class="line">int ledState = LOW;</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">void setup() {</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> // BOUNCE SETUP</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> // SELECT ONE OF THE FOLLOWING :</div>
|
||
|
<div class="line"> // 1) IF YOUR INPUT HAS AN INTERNAL PULL-UP</div>
|
||
|
<div class="line"> // bounce.attach( BOUNCE_PIN , INPUT_PULLUP ); // USE INTERNAL PULL-UP</div>
|
||
|
<div class="line"> // 2) IF YOUR INPUT USES AN EXTERNAL PULL-UP</div>
|
||
|
<div class="line"> bounce.attach( BOUNCE_PIN, INPUT ); // USE EXTERNAL PULL-UP</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> // DEBOUNCE INTERVAL IN MILLISECONDS</div>
|
||
|
<div class="line"> bounce.interval(5); // interval in ms</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> // LED SETUP</div>
|
||
|
<div class="line"> pinMode(LED_PIN, OUTPUT);</div>
|
||
|
<div class="line"> digitalWrite(LED_PIN, ledState);</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">}</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">void loop() {</div>
|
||
|
<div class="line"> // Update the Bounce instance (YOU MUST DO THIS EVERY LOOP)</div>
|
||
|
<div class="line"> bounce.update();</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> // <Bounce>.changed() RETURNS true IF THE STATE CHANGED (FROM HIGH TO LOW OR LOW TO HIGH)</div>
|
||
|
<div class="line"> if ( bounce.changed() ) {</div>
|
||
|
<div class="line"> // THE STATE OF THE INPUT CHANGED</div>
|
||
|
<div class="line"> // GET THE STATE</div>
|
||
|
<div class="line"> int deboucedInput = bounce.read();</div>
|
||
|
<div class="line"> // IF THE CHANGED VALUE IS LOW</div>
|
||
|
<div class="line"> if ( deboucedInput == LOW ) {</div>
|
||
|
<div class="line"> ledState = !ledState; // SET ledState TO THE OPPOSITE OF ledState</div>
|
||
|
<div class="line"> digitalWrite(LED_PIN,ledState); // WRITE THE NEW ledState</div>
|
||
|
<div class="line"> }</div>
|
||
|
<div class="line"> }</div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line"> </div>
|
||
|
<div class="line">}</div>
|
||
|
</div><!-- fragment --> </div><!-- contents -->
|
||
|
<!-- start footer part -->
|
||
|
<hr class="footer"/><address class="footer"><small>
|
||
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
||
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
||
|
</a> 1.8.17
|
||
|
</small></address>
|
||
|
</body>
|
||
|
</html>
|