<!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>

                      <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>

                      <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>

                      <h4>Water Level Sensor</h4>

                      <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>
                          /*
                         * 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>

                      <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...
                        </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>

                    <br>
                    <hr>
                    <br>

                    <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>
                        <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">&copy; 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>