Newer
Older
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
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="GitLab Pages">
<meta name="description" content="Fab Academy documentation site for Charlotte Fab-C">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="../assets/css/main.css" />
<title>Charlotte Fab-C - Fab Academy</title>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<!-- Main -->
<div id="main">
<div class="inner">
<!-- Header -->
<header id="header">
<a href="../index.html" class="logo"><strong>Charlotte - FabLab de Charleroi</strong> Fab Academy website</a>
<ul class="icons">
<li><a href="https://www.facebook.com/littlebelge" class="icon brands fa-facebook-f" target="_blank"><span class="label">Facebook</span></a></li>
<li><a href="https://www.instagram.com/little.belge/" class="icon brands fa-instagram" target="_blank"><span class="label">Instagram</span></a></li>
<li><a href="https://gitlab.fabcloud.org/charlotte-vandenbulcke" class="icon brands fa-gitlab" target="_blank"><span class="label">Gitlab</span></a></li>
</ul>
</header>
<!-- Section -->
<section id="banner">
<div class="content">
<header class="main">
<h2>11. Input Devices</h2>
</header>
<section>
<h3>Hero shot</h3>
<span class="object">
<video width="600" height="300" controls>
<source src="../images/soil-humidity-sensor.mp4" type="video/mp4">
</video>
</span>
<br>
</section>
<hr>
<section>
<h3>Group Assignment</h3>
<h4>Measuring HC-SR04 Ultrasonic sensor (infos from <a href="https://components101.com/sensors/ultrasonic-sensor-working-pinout-datasheet" target="_blank">Components 101</a>)</h4>
<p>This sensor is a very popular sensor used in many applications where measuring distance or sensing objects are required.</p>
<span class="image object">
<img src="../images/ultrasonic-distance-sensor.jpg" alt="...">
</span>
<p>The module has two eyes like projects in the front which forms the Ultrasonic transmitter and Receiver.</p>
<p>It is a 4 pin module, whose pin names are Vcc, Trigger, Echo and Ground respectively.</p>
<span class="image object">
<img src="../images/Ultrasonic-sensor-pinout.jpg" alt="...">
</span>
<h5>Applications</h5>
<ul>
<li>Used to avoid and detect obstacles with robots like biped robot, obstacle avoider robot, path finding robot etc.</li>
<li>Used to measure the distance within a wide range of 2cm to 400cm</li>
<li>Can be used to map the objects surrounding the sensor by rotating it</li>
<li>Depth of certain places like wells, pits etc can be measured since the waves can penetrate through water</li>
</ul>
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
<h5>Test with the Ultrasonic Sensor (from <a href="https://projecthub.arduino.cc/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-7cabe1" target="_blank">Project Hub Arduino</a>)</h5>
<pre>
<code>
/*
* HC-SR04 example sketch
*
* https://create.arduino.cc/projecthub/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-036380
*
* by Isaac100
*/
//define the pins that Trig and Echo are connected to
const int trigPin = 2;
const int echoPin = 1;
//declare 2 floats, duration and distance, which will hold the length of the sound wave and how far away the object is
float duration, distance;
void setup() {
pinMode(trigPin, OUTPUT); //declare the Trig pin as an output
pinMode(echoPin, INPUT); //declare the Echo pin as an input
Serial.begin(9600); //start Serial communications
}
void loop() {
digitalWrite(trigPin, LOW); //set the trigPin low for 2 microseconds just to make sure
delayMicroseconds(2); //that the pin in low first
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration*.0343)/2;
Serial.print("Pulse: ");
Serial.print(duration);
Serial.println("micro seconds");
Serial.print("Distance: ");
Serial.print(distance);
Serial.println("cm");
Serial.println(" ");
delay(1000);
}
</code>
</pre>
<span class="object">
<video width="600" height="300" controls>
<source src="../images/oscilloscope-measure-distance-sensor.mp4" type="video/mp4">
</video>
</span>
<p>Link to our <a href="https://fabacademy.org/2024/labs/fabc/group-assignment/week011/" target="_blank">Group page</a></p>
</section>
<hr>
<section>
<h3>Individual Assignment</h3>
<span class="image object">
<img src="../images/all-input-devices.jpg" alt="...">
</span>
<p>I've tested several input devices with programming codes found on internet to understand how they work and how useful they could be (mostly for my final project).</p>
<h4>Humidity and Temperature Sensor (infos from <a href="https://tutoduino.fr/en/beginners-corner/temperature-sensor/" target="_blank">Tuto Duino</a>)</h4>
<p>The DHT11 sensor measures temperature and humidity. The use of this type of sensor is interesting for a beginner because it makes it possible to measure a physical quantity accessible to all.</p>
<span class="image object">
<img src="../images/humidity-and-temperature-sensor.jpg" alt="..." />
</span>
<h5>Pinouts</h5>
<p>The DHT11 sensor has 4 pins, but is often sold on a carrier board which has 3 pins. It communicates with the Arduino very simply through one of its digital inputs. The other 2 pins are for its 5V supply and ground (GND).</p>
<span class="image object">
<img src="../images/dht11-pinouts.jpg" alt="..." />
</span>
<h5>Test with the Humidity and Temperature Sensor</h5>
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
<pre>
<code>
#include < DHT.h>
#define DHTPIN 9
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
float temp;
float hum;
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
hum = dht.readHumidity();
temp = dht.readTemperature();
if (isnan(hum) || isnan(temp)) {
Serial.println("Error reading from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print("%\t");
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println(" *C");
delay(2000);
}
</code>
</pre>
<span class="object">
<video width="600" height="300" controls>
<source src="../images/humidity-and-temperature.mp4" type="video/mp4">
</video>
</span>
<hr>
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
<span class="image object">
<img src="../images/water-sensor.jpg" alt="..." />
<caption>Water Sensor</caption>
</span>
<h5>Water Level Sensor Pinout (infos form <a href="https://arduinogetstarted.com/tutorials/arduino-water-sensor" target="_blank"><strong>Arduino Get Started</strong></a>)</h5>
<p>The water level sensor has 3 pins:</p>
<ul>
<li>S (Signal) pin: is an analog output that will be connected to one of the analog inputs on your Arduino.</li>
<li>+ (VCC) pin: supplies power for the sensor. It is recommended to power the sensor with between 3.3V – 5V.</li>
<li>- (GND) pin: is a ground connection.</li>
</ul>
<span class="image object">
<img src="../images/water-sensor-pinout.WebP" alt="..." />
<caption>Water Sensor pinouts</caption>
</span>
<p>The analog output value on the signal pin varies depending on the voltage supplied to the VCC pin of the sensor.</p>
<h5>How Water Level Sensor Works</h5>
<p>Simply, The more water the sensor is immersed in, the higher the output voltage in the signal pin is.</p>
<h5>Test with the Water Sensor</h5>
<span class="image object">
<img src="../images/water-sensor-test.jpg" alt="...">
<caption>Test with the Water Sensor</caption>
</span>
<pre>
<code>
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
/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-water-sensor
*/
#define POWER_PIN 14
#define SIGNAL_PIN A0
int value = 0; // variable to store the sensor value
void setup() {
Serial.begin(9600);
pinMode(POWER_PIN, OUTPUT); // configure D7 pin as an OUTPUT
digitalWrite(POWER_PIN, LOW); // turn the sensor OFF
}
void loop() {
digitalWrite(POWER_PIN, HIGH); // turn the sensor ON
delay(10); // wait 10 milliseconds
value = analogRead(SIGNAL_PIN); // read the analog value from sensor
digitalWrite(POWER_PIN, LOW); // turn the sensor OFF
Serial.print("Sensor value: ");
Serial.println(value);
delay(1000);
}
</code>
</pre>
<span class="object">
<video width="600" height="300" controls>
<source src="../images/water-sensor.mp4" type="video/mp4">
</video>
</span>
<hr>
<h4>Soil Moisture Sensor (infos from <a href="https://maker.pro/arduino/projects/arduino-soil-moisture-sensor" target="_blank">Maker Pro</a>)</h4>
<p>The soil moisture sensor consists of two probes that are used to measure the volumetric content of water. The two probes allow the current to pass through the soil, which gives the resistance value to measure the moisture value.</p>
<span class="image object">
<img src="../images/soil-humidity-sensor.jpg" alt="..." />
</span>
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
319
320
321
322
323
324
325
<span class="image object">
<img src="../images/moisture-sensor.jpg" alt="..." />
</span>
<p>When there is water, the soil will conduct more electricity, which means that there will be less resistance. Dry soil conducts electricity poorly, so when there is less water, then the soil will conduct less electricity, which means that there will be more resistance.</p>
<p>This sensor can be connected in analog and digital modes. First, we will connect it in analog mode, and then digital.</p>
<h5>Specifications</h5>
<p>The specifications of the FC-28 soil moisture sensor are as follows:</p>
<ul>
<li>Input Voltage: 3.3–5V</li>
<li>Output Voltage: 0–4.2V</li>
<li>Input Current: 35mA</li>
<li>Output Signal: both analog and digital</li>
</ul>
<h5>Pin-out</h5>
<p>The FC-28 soil moisture sensor has four pins:</p>
<ul>
<li>VCC: Power</li>
<li>A0: Analog Output</li>
<li>D0: Digital Output</li>
<li>GND: Ground</li>
</ul>
<span class="image object">
<img src="../images/sensor-moisture-pinout.WebP" alt="...">
</span>
<p>The module also contains a potentiometer, which will set the threshold value. This threshold value will be compared by the LM393 comparator. The output LED will light up and down according to this threshold value.</p>
<h5>Test with the Soil Moisture Sensor</h5>
<span class="image object">
<img src="../images/soil-humidity-sensor-test.jpg" alt="...">
</span>
<p>
<blockquote>
I failed this week in saving the different codes. When I started documenting my work I discovered that I saved all my Arduino files with the wrong name of sensor... So I had to play "puzzle" with the files and some are missing at the end, like this one.
I will have to start again on this one to be able to share the code.
</blockquote>
</p>
<pre>
<code>
Will come soon...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
</code>
</pre>
<span class="object">
<video width="600" height="300" controls>
<source src="../images/soil-humidity-sensor.mp4" type="video/mp4">
</video>
</span>
<hr>
<h4>KY-037 Big Sound Sensor (infos from <a href="https://electropeak.com/learn/interfacing-ky-037-sound-sensor-with-arduino/" target="_blank">Electro Peak !</a>)</h4>
<p>KY-037 module consists of a capacitive microphone and an amplifier circuit. The output of this module is both analog and digital.</p>
<span class="image object">
<img src="../images/big-sound-sensor.jpg" alt="..." />
</span>
<h5>KY-037 Sound Module Pinout</h5>
<p>This module has 4 pins, 2 of them are for power supply.</p>
<p>Pin 1: The analog output. It’s value changes according to the intensity of the received sound. It can be connected to the Arduino analog (ADC) pins.</p>
<p>Pin 4: The digital output. It acts as a key, and it activates when sound intensity has reached a certain threshold. The sensitivity threshold can be adjusted using the potentiometer on the sensor.</p>
<span class="image object">
<img src="../images/big-sound-pinout.jpg" alt="..." />
</span>
<h5>Test with the Big Sound Sensor</h5>
<pre>
<code>
/*
modified on June 5, 2018
by Arduino Examples from arduino.cc/en/Tutorial/ReadAnalogVoltage
Home
*/
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(50);
}
</code>
</pre>
<span class="object">
<video width="600" height="300" controls>
<source src="../images/big-sound.mp4" type="video/mp4">
</video>
</span>
<hr>
<h4>Hall Magnetic Sensor (infos from <a href="https://techiescience.com/hall-effect-sensor-arduino/" target="_blank">Techiescience</a>)</h4>
<p>The Hall Effect Sensor Arduino is a device that allows you to measure magnetic fields.</p>
<span class="image object">
<img src="../images/hall-magnetic-sensor.jpg" alt="..." />
</span>
<p>The sensor consists of a thin strip of semiconductor material, typically made of gallium arsenide or indium antimonide. This strip is placed in a magnetic field, and when a current flows through it, the Hall effect occurs.</p>
<h5>Pinouts</h5>
<p>The module has 3 output points; Power, Ground, and Signal.</p>
<span class="image object">
<img src="../images/hall-magnetic-Pinout.jpg" alt="..." />
</span>
<h5>Applications</h5>
<ul>
<li>Motor control</li>
<li>Metal detector</li>
<li>Position sensing</li>
<li>Magnetic Code Reading</li>
<li>Current sensing</li>
</ul>
<h5>Test with the Hall Magnetic Sensor</h5>
<pre>
<code>
int Led = 26 ; // Led declaration on pin 26
int SENSOR = 4 ; // Sensor declaration on pin 4
int val ; // Variable number declaration
void setup (){
pinMode (Led, OUTPUT) ; // Define LED as output
pinMode (SENSOR, INPUT) ; // Define Sensor as input
}
void loop (){
val = digitalRead (SENSOR) ; // Reading sensor status
if (val == LOW) { // When sensor detects a magnet, LED 26 goes on
digitalWrite (Led, HIGH);
}
{
digitalWrite (Led, LOW);
}
}
</code>
</pre>
<span class="object">
<video width="600" height="300" controls>
<source src="../images/hall-magnetic.mp4" type="video/mp4">
</video>
</span>
</section>
<h3>Files and resources</h3>
<p><strong>My files</strong></p>
<ul>
<li><a href="../files/humidity_and_temperature.ino" target="_blank">Humidity and Temperature Arduino file</a></li>
<li><a href="../files/water-sensor.ino" target="_blank">Water Sensor Arduino file</a></li>
<li><a href="../files/BigSound.ino" target="_blank">Big Sound Arduino file</a></li>
<li><a href="../files/HallMagnetic.ino" target="_blank">Hall Magnetic Arduino file</a></li>
</ul>
<p><strong>Resources</strong></p>
<ul>
<li><a href="https://components101.com/" target="_blank">Components 101 website</a></li>
<li><a href="https://arduinogetstarted.com/" target="_blank">Arduino Get Started website</a></li>
<li><a href="https://maker.pro/" target="_blank">Maker Pro website</a></li>
<li><a href="https://electropeak.com/" target="_blank">Electro Peak ! website</a></li>
<li><a href="https://techiescience.com/" target="_blank">Techiescience website</a></li>
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<li><a href="https://fabacademy.org/2024/labs/fabc/" target="_blank">Our group page</a></li>
</ul>
</section>
</div>
</section>
</div>
</div>
<!-- Sidebar -->
<div id="sidebar">
<div class="inner">
<!-- Menu -->
<nav id="menu">
<header class="major">
<h2>Menu</h2>
</header>
<ul>
<li><a href="../index.html">Homepage</a></li>
<li><a href="../assignments.html">Assignments</a></li>
<li>
<span class="opener">Week per week</span>
<ul>
<li><a href="../assignments/week01.html">1. Project Management</a></li>
<li><a href="../assignments/week02.html">2. Computer Aided Design</a></li>
<li><a href="../assignments/week03.html">3. Computer Controlled Cutting</a></li>
<li><a href="../assignments/week04.html">4. Electronics Production</a></li>
<li><a href="../assignments/week05.html">5. 3D Scanning And Printing</a></li>
<li><a href="../assignments/week06.html">6. Embedded Programming</a></li>
<li><a href="../assignments/week07.html">7. Computer Controlled Machining</a></li>
<li><a href="../assignments/week08.html">8. Electronics Design</a></li>
<li><a href="../assignments/week09.html">9. Output Devices</a></li>
<li><a href="../assignments/week10.html">10. Mechanical Design And Machine Design</a></li>
<li><a href="../assignments/week11.html">11. Input Devices</a></li>
<li><a href="../assignments/week12.html">12. Molding and Casting</a></li>
<li><a href="../assignments/week13.html">13. Networking And Communications</a></li>
<li><a href="../assignments/week14.html">14. Interface And Application Programming</a></li>
<li><a href="../assignments/week15.html">15. Wildcard Week</a></li>
<li><a href="../assignments/week16.html">16. Applications And Implications</a></li>
<li><a href="../assignments/week17.html">17. Invention, Intellectual Property And Income</a></li>
<li><a href="../assignments/week18.html">18. Project Development</a></li>
</ul>
</li>
<li><a href="../final-project.html">Final Project</a></li>
<li><a href="../about.html">About Me</a></li>
</nav>
<!-- Footer -->
<footer id="footer">
<p class="copyright">© Charlotte - FabLab de Charleroi. Fab Academy 2024. All rights reserved. Design: <a href="https://html5up.net">HTML5 UP</a>.</p>
</footer>
</div>
</div>
</div>
<!-- Scripts -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/browser.min.js"></script>
<script src="../assets/js/breakpoints.min.js"></script>
<script src="../assets/js/util.js"></script>
<script src="../assets/js/main.js"></script>
</body>
</html>