-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcirc08.html
318 lines (301 loc) · 12.5 KB
/
circ08.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>ardx:circ-08[.:wcrs:.]</title>
<meta name="description" content="Arduino Experimenters Kit Potentiometers circuit">
<!-- #include «head.html» -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--[if IE]><link rel="shortcut icon" href="favicon.ico"><![endif]-->
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="icon" href="favicon.png">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- #include «topnav.html» -->
<nav id="topnav">
<a id="logo" href="https://wcrsyyc.github.io/"><img
src="img/wcrs_logo.png" alt="logo"></a>
<h2><a href="index.html">WCRS</a></h2>
<ul>
<li><a href="https://github.com/WCRSyyc/ardx">about</a> |</li>
<li><a href="https://github.com/WCRSyyc/ardx/issues">contact</a> |</li>
<li><a href="https://github.com/WCRSyyc/ardx/wiki">wiki</a></li>
</ul>
<hr>
<p><!-- current message text --></p>
</nav>
<!-- #include «sidebar.html» -->
<nav id="sidebar">
<section id="menu">
<ul>
<li><h2>PRODUCTS</h2>
<ul>
<li><a href="https://github.com/WCRSyyc/ardx/"><h3>(WCRS)</h3>ARDX additions</a>
<ul>
<li><a href="preface.html">
<h4>ABOUT</h4>A Few Words</a></li>
<!-- <li><a href="assembling.html">
<h4>ASSMB</h4>Putting It Together</a></li> -->
<li><a href="starthere.html">
<h4>START</h4>Startup Links</a></li>
<li><a href="programming.html">
<h4>PROG</h4>Programming Primer</a></li>
<li><a href="electronics.html">
<h4>ELEC</h4>Electronics Primer</a></li>
<li><a href="fritzing.html">
<h4>FRITZING</h4>Fritzing with ARDX</a></li>
<li><a href="circ01.html">
<h4>CIRC-01</h4>Blinking LED</a></li>
<li><a href="circ02.html">
<h4>CIRC-02</h4>Multiple LEDs</a></li>
<li><a href="circ03.html">
<h4>CIRC-03</h4>Transistors & Motors</a></li>
<li><a href="circ04.html">
<h4>CIRC-04</h4>Servos</a></li>
<li><a href="circ05.html">
<h4>CIRC-05</h4>74HC595 Shift Registers</a></li>
<li><a href="circ06.html">
<h4>CIRC-06</h4>Piezo Speaker</a></li>
<li><a href="circ07.html">
<h4>CIRC-07</h4>Pushbuttons</a></li>
<li><a href="circ08.html">
<h4>CIRC-08</h4>Potentiometers</a></li>
<li><a href="circ09.html">
<h4>CIRC-09</h4>Photo-Resistors</a></li>
<li><a href="circ10.html">
<h4>CIRC-10</h4>Temperature</a></li>
<li><a href="circ11.html">
<h4>CIRC-11</h4>Relays</a></li>
<li><a href="circ12.html">
<h4>CIRC-12</h4>RGB LED blink</a></li>
<li><a href="circ15.html">
<h4>CIRC-15</h4>Dice Simulator</a></li>
</ul>
</li>
<li><a href="https://github.com/WCRSyyc/ardx/"><h3>(WCRS)</h3>Python ARDX</a>
<ul>
<!-- <li><a href="preface.html">
<h4>ABOUT</h4>A Few Words</a></li> -->
<!-- <li><a href="assembling.html">
<h4>ASSMB</h4>Putting It Together</a></li> -->
<!-- <li><a href="starthere.html">
<h4>START</h4>Startup Links</a></li> -->
<!-- <li><a href="programming.html">
<h4>PROG</h4>Programming Primer</a></li> -->
<li><a href="electronics.html">
<h4>ELEC</h4>Electronics Primer</a></li>
<li><a href="fritzing.html">
<h4>FRITZING</h4>Fritzing with ARDX</a></li>
<li><a href="ArdxPythonHowTo.html">
<h4>GUIDE</h4>Python Guide</a></li>
<!--
<li><a href="circ01p.html">
<h4>CIRC-01</h4>Blinking LED</a></li>
<li><a href="circ02p.html">
<h4>CIRC-02</h4>Multiple LEDs</a></li>
<li><a href="circ03p.html">
<h4>CIRC-03</h4>Transistors & Motors</a></li>
<li><a href="circ04p.html">
<h4>CIRC-04</h4>Servos</a></li>
<li><a href="circ05p.html">
<h4>CIRC-05</h4>74HC595 Shift Registers</a></li>
<li><a href="circ06p.html">
<h4>CIRC-06</h4>Piezo Speaker</a></li>
<li><a href="circ07p.html">
<h4>CIRC-07</h4>Pushbuttons</a></li>
<li><a href="circ08p.html">
<h4>CIRC-08</h4>Potentiometers</a></li>
<li><a href="circ09p.html">
<h4>CIRC-09</h4>Photo-Resistors</a></li>
<li><a href="circ10p.html">
<h4>CIRC-10</h4>Temperature</a></li>
<li><a href="circ11p.html">
<h4>CIRC-11</h4>Relays</a></li>
<li><a href="circ12p.html">
<h4>CIRC-12</h4>RGB LED blink</a></li>
<li><a href="circ15p.html">
<h4>CIRC-15</h4>Dice Simulator</a></li> -->
</ul>
</li>
<li><a href="http://www.oomlout.com/a/products/ardx/"><h3>(ARDX)</h3>arduino / netduino experimenter´s kit</a>
</li>
</ul>
</li>
</ul>
</section>
<section>
<h3><a rel="license" href="http://creativecommons.org/licenses/by/4.0/">
<img alt="Creative Commons License"
src="img/80x15.png"></a></h3>
This work is licensed under a <a rel="license"
href="http://creativecommons.org/licenses/by/4.0/">Creative Commons
Attribution 4.0 International License</a>.
</section>
</nav>
<main id="circ-08">
<header>
<h1>CIRC<br/>08</h1>
<h2>.:Twisting:.<br/>.:Potentiometers:.</h2>
<img src="img/experiments/CIRC-08-square-100.jpg" width="100" height="100" alt="blue potentiometer on breadboard">
</header>
<h2>(ARDX) .:Arduino Experimentation Kit:. (ARDX)</h2>
<section>
<h2>What We're Doing</h2>
<p>Along with the digital pins, the Arduino also has 6 pins which can be used for analog input. These inputs take a voltage (from 0 to 5 volts) and convert it to a digital number between 0 (0 volts) and 1023 (5 volts) (10 bits of resolution). A very useful device that exploits these inputs is a potentiometer (also called a variable resistor). When it is connected with 5 volts across its outer pins the middle pin will read some value between 0 and 5 volts dependent on the angle to which it is turned (ie. 2.5 volts in the middle). We can then use the returned values as a variable in our program.</p>
</section>
<section id="circuit">
<h2>The Circuit</h2>
<div id="CIRC-theparts">
<h3>The Parts</h3>
<table>
<tr>
<td><img src="img/parts/CIRC-08-3dsheet-60.png"
width="60" height="36" alt="circuit 8 breadboard sheet 3d view"/></td>
<td>CIRC-08<br/>Breadboard Sheet<br/>x1</td>
<td><img src="img/parts/HEAD-02-60.png"
width="60" height="36" alt="2 pin header"/></td>
<td>2 Pin Header<br/>x4</td>
<td><img src="img/parts/POT-103-60.png"
width="60" height="36" alt="small potentiometer"/></td>
<td>Wire</td>
<td><img src="img/parts/WIRE-01-60.png"
width="60" height="36" alt="male-male dupont jumper wire"/></td>
<td>Wire</td>
</tr><tr>
<td><img src="img/parts/LED-05G-60.png"
width="60" height="36" alt="through hole green LED"/></td>
<td>Green LED<br/>x1</td>
<td><img src="img/parts/RES-561-60.png"
width="60" height="36" alt="through hole resistor"/></td>
<td>560 Ohm Resistor<br/>Green-Blue-Black-Black<br/>x1</td>
<td colspan="4"></td>
</tr>
</table>
</div>
<span class="bb-svg-container"><svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="25 13 75 75"
preserveAspectRatio="xMaxYMin meet">
<image height="100" width="100"
xlink:href="img/experiments/CIRC08-bb.svg"/>
</svg></span>
<div>
<h3>Schematic</h3>
<span class="sch-svg-container"><svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="61 26 36 36"
preserveAspectRatio="xMidYMin meet">
<image height="100" width="100"
xlink:href="img/experiments/CIRC08-sch.svg" />
</svg></span>
</div>
<div>
<h3>Resources</h3>
<h4>.:download:.</h4>
<p>Breadboard layout sheet<br/>
<a href="img/experiments/CIRC08-sheet-OOML.pdf">http://ardx.org/BBLS08</a>
</p>
<p>Fritzing diagram<br/><a href="fritzing/CIRC08.fzz">
https://wcrsyyc.github.io/ardx/fritzing/CIRC08.fzz</a></p>
<h4>.:view:.</h4>
<p>
assembly video<br/>
<a href="https://www.youtube.com/watch?v=pM5J7yIaTUw">http://ardx.org/VIDE08</a>
</p>
</div>
</section>
<section id="code">
<h2>Code <span>(no need to type everything in just)</span></h2>
<h3>File > Examples > 3.Analog > AnalogInput</h3>
<p>(example from the great <a href="https://www.arduino.cc/">arduino.cc</a> site, check it out for other ideas)</p>
<pre>/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
* Note: because most Arduinos have a built-in LED attached
to pin 13 on the board, the LED is optional.
Created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}</pre>
</section>
<section id="CIRC-notworking">
<h2>Not Working? <span>(3 things to try)</span></h2>
<div>
<h3>Sporadically Working</h3>
<p>This is most likely due to a slightly dodgy connection with the potentiometer's pins. This can usually be conquered by taping the potentiometer down.</p>
</div>
<div>
<h3>Not Working</h3>
<p>Make sure you haven't accidentally connected the potentiometer's wiper to digital pin 0 rather than analog pin 0. (the row of pins beneath the power pins)</p>
</div>
<div>
<h3>Still Backward</h3>
<p>You can try operating the circuit upside down. Sometimes this helps.</p>
</div>
</section>
<section id="CIRC-makingBetter">
<h2>Making it Better?</h2>
<h3>Threshold Switching:</h3>
<p>Sometimes you will want to switch an output when a value exceeds a certain threshold. To do this with a potentiometer change the loop() code to.</p>
<pre>void loop() {
int threshold = 512;
if(analogRead(potPin) > threshold){ digitalWrite(ledPin, HIGH);}
else{ digitalWrite(ledPin, LOW);}
}</pre>
<p>This will cause the LED to turn on when the value is above 512 (about halfway), you can adjust the sensitivity by changing the threshold value.</p>
<h3>Fading:</h3>
<p>Lets control the brightness of an LED directly from the potentiometer. To do this we need to first change the pin the LED is connected to. Move the wire from pin 13 to pin 9 and change one line in the code.<br/>
<code>int ledPin = 13;</code> ----> <code>int ledPin = 9;</code><br/>
Then change the loop code to.</p>
<pre>void loop() {
int value = analogRead(potPin) / 4;
analogWrite(ledPin, value);
}</pre>
<p>Upload the code and watch as your LED fades in relation to your potentiometer spinning. (Note: the reason we divide the value by 4 is the analogRead() function returns a value from 0 to 1023 (10 bits), and analogWrite() takes a value from 0 to 255 (8 bits) )</p>
<h3>Controlling a Servo:</h3>
<p>This is a really neat example and brings a couple of circuits together. Wire up the servo like you did in CIRC-04, without changing the potentiometer wiring. Then open the example program Knob (File > Examples > Library-Servo > Knob ), upload to your Arduino and watch the servo shaft rotate as you turn the potentiometer.</p>
</section>
</main>
<footer>.:Welcome to the Bottom:.</footer>
</body>
</html>