forked from rweather/arduinolibs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Charlieplex_8cpp_source.html
235 lines (233 loc) · 24.4 KB
/
Charlieplex_8cpp_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!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"/>
<title>ArduinoLibs: Charlieplex.cpp Source File</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.1.2 -->
<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><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 class="current"><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>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></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 id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_bc0718b08fb2015b8e59c47b2805f60c.html">libraries</a></li><li class="navelem"><a class="el" href="dir_1586d320a3b1e622174530fde769cda9.html">BlinkLED</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Charlieplex.cpp</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Copyright (C) 2012 Southern Storm Software, Pty Ltd.</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * copy of this software and associated documentation files (the "Software"),</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * to deal in the Software without restriction, including without limitation</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> * Software is furnished to do so, subject to the following conditions:</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> *</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * The above copyright notice and this permission notice shall be included</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * in all copies or substantial portions of the Software.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> *</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment"> * DEALINGS IN THE SOFTWARE.</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="comment"> */</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include "Charlieplex.h"</span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#if defined(ARDUINO) && ARDUINO >= 100</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor"></span><span class="preprocessor">#include <Arduino.h></span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#else</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="preprocessor"></span><span class="preprocessor">#include <WProgram.h></span></div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="preprocessor"></span><span class="preprocessor">#include <stdlib.h></span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="preprocessor">#include <string.h></span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span> </div>
<div class="line"><a name="l00121"></a><span class="lineno"><a class="code" href="classCharlieplex.html#abfb0d0456bcbadbf60c21f615adacdbd"> 121</a></span> <a class="code" href="classCharlieplex.html#abfb0d0456bcbadbf60c21f615adacdbd" title="Constructs a new charliexplexing array where the output pins are specified by the numPins entries in ...">Charlieplex::Charlieplex</a>(<span class="keyword">const</span> uint8_t *pins, uint8_t numPins)</div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  : _count(((int)numPins) * (numPins - 1))</div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  , _lastTime(micros())</div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  , _currentIndex(-1)</div>
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  , _pwmPhase(0xC0)</div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span> {</div>
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <span class="comment">// Determine the best hold time for 50 Hz refresh when all LED's</span></div>
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="comment">// are lit. Divide it again by 4 (to get 200 Hz) to manage the</span></div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="comment">// simulated PWM in refresh().</span></div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  _holdTime = 20000 / _count / 4;</div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span> </div>
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <span class="comment">// Allocate the pin arrays and populate them. Doing this now makes</span></div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="comment">// refresh() more efficient later, at the expense of some memory.</span></div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  _pins1 = (uint8_t *)malloc(_count);</div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  _pins2 = (uint8_t *)malloc(_count);</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keywordtype">int</span> n = 0;</div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keywordflow">for</span> (uint8_t pass = 1; pass < numPins; ++pass) {</div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keywordflow">for</span> (uint8_t pin = 0; pin < (numPins - pass); ++pin) {</div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  _pins1[n] = _pins2[n + 1] = pins[pin];</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  _pins2[n] = _pins1[n + 1] = pins[pin + pass];</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  n += 2;</div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  }</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  }</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span> </div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="comment">// Allocate space for the LED value array and zero it.</span></div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  _values = (uint8_t *)malloc(_count);</div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  memset(_values, 0, _count);</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span> </div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="comment">// Start with all pins configured as floating inputs (all LED's off).</span></div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <span class="keywordflow">for</span> (uint8_t pin = 0; pin < numPins; ++pin) {</div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  digitalWrite(pins[pin], LOW);</div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  pinMode(pins[pin], INPUT);</div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  }</div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span> }</div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span> </div>
<div class="line"><a name="l00159"></a><span class="lineno"><a class="code" href="classCharlieplex.html#a4dbe37ccba8ba18139f4e710afdcd103"> 159</a></span> <a class="code" href="classCharlieplex.html#a4dbe37ccba8ba18139f4e710afdcd103" title="Destroys this charlieplexed array.">Charlieplex::~Charlieplex</a>()</div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span> {</div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  free(_pins1);</div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  free(_pins2);</div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  free(_values);</div>
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span> }</div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span> </div>
<div class="line"><a name="l00277"></a><span class="lineno"><a class="code" href="classCharlieplex.html#a8313edeacd8387c428b8299d52584d6a"> 277</a></span> <span class="keywordtype">void</span> <a class="code" href="classCharlieplex.html#a8313edeacd8387c428b8299d52584d6a" title="Runs the multiplexing loop, to display the LED states on the charlieplexed array.">Charlieplex::loop</a>()</div>
<div class="line"><a name="l00278"></a><span class="lineno"> 278</span> {</div>
<div class="line"><a name="l00279"></a><span class="lineno"> 279</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> us = micros();</div>
<div class="line"><a name="l00280"></a><span class="lineno"> 280</span>  <span class="keywordflow">if</span> ((us - _lastTime) >= _holdTime) {</div>
<div class="line"><a name="l00281"></a><span class="lineno"> 281</span>  _lastTime = us;</div>
<div class="line"><a name="l00282"></a><span class="lineno"> 282</span>  <a class="code" href="classCharlieplex.html#a3c961bfff866e400dad371f0376f096b" title="Refreshes the charlieplexed array by advancing to the next LED that needs to be lit.">refresh</a>();</div>
<div class="line"><a name="l00283"></a><span class="lineno"> 283</span>  }</div>
<div class="line"><a name="l00284"></a><span class="lineno"> 284</span> }</div>
<div class="line"><a name="l00285"></a><span class="lineno"> 285</span> </div>
<div class="line"><a name="l00296"></a><span class="lineno"><a class="code" href="classCharlieplex.html#a3c961bfff866e400dad371f0376f096b"> 296</a></span> <span class="keywordtype">void</span> <a class="code" href="classCharlieplex.html#a3c961bfff866e400dad371f0376f096b" title="Refreshes the charlieplexed array by advancing to the next LED that needs to be lit.">Charlieplex::refresh</a>()</div>
<div class="line"><a name="l00297"></a><span class="lineno"> 297</span> {</div>
<div class="line"><a name="l00298"></a><span class="lineno"> 298</span>  <span class="comment">// Find the next LED to be lit.</span></div>
<div class="line"><a name="l00299"></a><span class="lineno"> 299</span>  <span class="keywordtype">int</span> prevIndex = _currentIndex;</div>
<div class="line"><a name="l00300"></a><span class="lineno"> 300</span>  <span class="keywordtype">int</span> limit = _count;</div>
<div class="line"><a name="l00301"></a><span class="lineno"> 301</span>  <span class="keywordflow">while</span> (limit >= 0) {</div>
<div class="line"><a name="l00302"></a><span class="lineno"> 302</span>  _currentIndex = (_currentIndex + 1) % _count;</div>
<div class="line"><a name="l00303"></a><span class="lineno"> 303</span>  <span class="keywordflow">if</span> (_values[_currentIndex] != 0)</div>
<div class="line"><a name="l00304"></a><span class="lineno"> 304</span>  <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00305"></a><span class="lineno"> 305</span>  --limit;</div>
<div class="line"><a name="l00306"></a><span class="lineno"> 306</span>  }</div>
<div class="line"><a name="l00307"></a><span class="lineno"> 307</span>  <span class="keywordflow">if</span> (limit < 0) {</div>
<div class="line"><a name="l00308"></a><span class="lineno"> 308</span>  <span class="comment">// No LED's are lit. Turn off the previous LED and exit.</span></div>
<div class="line"><a name="l00309"></a><span class="lineno"> 309</span>  <span class="keywordflow">if</span> (prevIndex != -1) {</div>
<div class="line"><a name="l00310"></a><span class="lineno"> 310</span>  digitalWrite(_pins1[prevIndex], LOW);</div>
<div class="line"><a name="l00311"></a><span class="lineno"> 311</span>  digitalWrite(_pins2[prevIndex], LOW);</div>
<div class="line"><a name="l00312"></a><span class="lineno"> 312</span>  pinMode(_pins1[prevIndex], INPUT);</div>
<div class="line"><a name="l00313"></a><span class="lineno"> 313</span>  pinMode(_pins2[prevIndex], INPUT);</div>
<div class="line"><a name="l00314"></a><span class="lineno"> 314</span>  }</div>
<div class="line"><a name="l00315"></a><span class="lineno"> 315</span>  _currentIndex = -1;</div>
<div class="line"><a name="l00316"></a><span class="lineno"> 316</span>  <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00317"></a><span class="lineno"> 317</span>  }</div>
<div class="line"><a name="l00318"></a><span class="lineno"> 318</span> </div>
<div class="line"><a name="l00319"></a><span class="lineno"> 319</span>  <span class="comment">// Light the current LED.</span></div>
<div class="line"><a name="l00320"></a><span class="lineno"> 320</span>  uint8_t value = _values[_currentIndex];</div>
<div class="line"><a name="l00321"></a><span class="lineno"> 321</span>  uint8_t pin1 = _pins1[_currentIndex];</div>
<div class="line"><a name="l00322"></a><span class="lineno"> 322</span>  uint8_t pin2 = _pins2[_currentIndex];</div>
<div class="line"><a name="l00323"></a><span class="lineno"> 323</span>  _pwmPhase += 0x40;</div>
<div class="line"><a name="l00324"></a><span class="lineno"> 324</span>  <span class="keywordflow">if</span> (prevIndex != _currentIndex) {</div>
<div class="line"><a name="l00325"></a><span class="lineno"> 325</span>  <span class="comment">// Turn off the previous LED.</span></div>
<div class="line"><a name="l00326"></a><span class="lineno"> 326</span>  <span class="keywordflow">if</span> (prevIndex != -1) {</div>
<div class="line"><a name="l00327"></a><span class="lineno"> 327</span>  digitalWrite(_pins1[prevIndex], LOW);</div>
<div class="line"><a name="l00328"></a><span class="lineno"> 328</span>  digitalWrite(_pins2[prevIndex], LOW);</div>
<div class="line"><a name="l00329"></a><span class="lineno"> 329</span>  pinMode(_pins1[prevIndex], INPUT);</div>
<div class="line"><a name="l00330"></a><span class="lineno"> 330</span>  pinMode(_pins2[prevIndex], INPUT);</div>
<div class="line"><a name="l00331"></a><span class="lineno"> 331</span>  }</div>
<div class="line"><a name="l00332"></a><span class="lineno"> 332</span> </div>
<div class="line"><a name="l00333"></a><span class="lineno"> 333</span>  <span class="comment">// We simulate PWM using a phase counter because analogWrite()</span></div>
<div class="line"><a name="l00334"></a><span class="lineno"> 334</span>  <span class="comment">// combined with holdTime() causes too much flickering if more</span></div>
<div class="line"><a name="l00335"></a><span class="lineno"> 335</span>  <span class="comment">// than one LED is lit. This reduces the PWM resolution to 1 in 4.</span></div>
<div class="line"><a name="l00336"></a><span class="lineno"> 336</span>  pinMode(pin1, OUTPUT);</div>
<div class="line"><a name="l00337"></a><span class="lineno"> 337</span>  pinMode(pin2, OUTPUT);</div>
<div class="line"><a name="l00338"></a><span class="lineno"> 338</span>  <span class="keywordflow">if</span> (value > _pwmPhase)</div>
<div class="line"><a name="l00339"></a><span class="lineno"> 339</span>  digitalWrite(pin1, HIGH);</div>
<div class="line"><a name="l00340"></a><span class="lineno"> 340</span>  <span class="keywordflow">else</span></div>
<div class="line"><a name="l00341"></a><span class="lineno"> 341</span>  digitalWrite(pin1, LOW);</div>
<div class="line"><a name="l00342"></a><span class="lineno"> 342</span>  } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00343"></a><span class="lineno"> 343</span>  <span class="comment">// Same LED as previous. Since there is only a single LED</span></div>
<div class="line"><a name="l00344"></a><span class="lineno"> 344</span>  <span class="comment">// that is lit, we can use analogWrite() to set the PWM state.</span></div>
<div class="line"><a name="l00345"></a><span class="lineno"> 345</span>  <span class="keywordflow">if</span> (value == 255)</div>
<div class="line"><a name="l00346"></a><span class="lineno"> 346</span>  digitalWrite(pin1, HIGH);</div>
<div class="line"><a name="l00347"></a><span class="lineno"> 347</span>  <span class="keywordflow">else</span></div>
<div class="line"><a name="l00348"></a><span class="lineno"> 348</span>  analogWrite(pin1, value);</div>
<div class="line"><a name="l00349"></a><span class="lineno"> 349</span>  }</div>
<div class="line"><a name="l00350"></a><span class="lineno"> 350</span> }</div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Sep 29 2013 09:30:46 for ArduinoLibs by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.2
</small></address>
</body>
</html>