<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Basic Page Needs
    ================================================== -->
    <meta charset="utf-8">
    <!--[if IE]><meta http-equiv="x-ua-compatible" content="IE=9" /><![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>week_09 Input Devices</title>
    <meta name="description" content="Your Description Here">
		<meta name="keywords" content="FabLab Taipei,FabLab,Zihao Lin,FabLab SCU">
    <meta name="author" content="Lin Zihao">

    <!-- Favicons
    ================================================== -->
    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" href="img/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114.png">

    <!-- Bootstrap -->
    <link rel="stylesheet" type="text/css"  href="css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="fonts/font-awesome/css/font-awesome.css">

    <!-- Slider
    ================================================== -->
    <link href="css/owl.carousel.css" rel="stylesheet" media="screen">
    <link href="css/owl.theme.css" rel="stylesheet" media="screen">

    <!-- Stylesheet
    ================================================== -->
    <link rel="stylesheet" type="text/css"  href="css/style.css">
    <link rel="stylesheet" type="text/css" href="css/responsive.css">


    <script type="text/javascript" src="js/modernizr.custom.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <!-- Navigation
    ==========================================-->
    <nav id="tf-menu" class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.html">Lin Zihao</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="index.html" class="page-scroll">Home</a></li>
            <li><a href="Final Project.html" class="page-scroll">Final Project</a></li>
            <li><a href="#tf-testimonials" class="page-scroll">Contact</a></li>
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav>

    <!-- Home Page
    ==========================================-->
    <div id="tf-home" class="text-center">
        <div class="overlay">
            <div class="content">
                <h1><strong><span class="color">week_09</span></strong></h1>
                <p class="lead"><strong>Input Devices</strong></p>
                <a href="#tf-services" class="fa fa-angle-down page-scroll"></a>
            </div>
        </div>
    </div>

    <!-- Services Section
    ==========================================-->
    <div id="tf-services">
        <div class="container">
            <div class="text-center">
              <div class="section-title center" >
                <h2><strong>Objectives</strong></h2>
                <div class="line">
                    <hr>
                </div>
              </div>
            </div>
                <ul class="about-list" class="pull-left">
                    <li>
                        <span class="fa fa-dot-circle-o"></span>
                        <strong>1)</strong> - <em>Knowledge of common input devices.</em>
                    </li>
                </ul>
                      <br />
            <div class="text-center">
              <div class="section-title center" >
                      <h2><strong>Assignments</strong></h2>
                      <div class="line">
                          <hr>
                      </div>
                    </div>
                  </div>
                      <ul class="about-list">
                          <li>
                              <span class="fa fa-dot-circle-o"></span>
                              <strong>1)</strong> - <em> Individual assignment: measure something: add a sensor to a microcontroller board that you have designed and read it.</em>
                          </li>
                          <li>
                              <span class="fa fa-dot-circle-o"></span>
                              <strong>2)</strong> - <em> Group assignment: probe an input device's analog levels and digital signals.</em>
                          </li>
                      </ul>
                            <br />
                <div class="text-center">
                   <div class="section-title center" >
                      <h2><strong>Individual assignment</strong></h2>
                        <div class="line">
                          <hr>
                        </div>
                    </div>
                  </div>
                  <p>This week we’re exploring input devices, i.e. how our microcontroller boards can start sensing the physical world. For my final project I need sensor for monitoring the illuminance of the smart socket. so, I decided to make one this week. So, the first I decided to put HC-SR04 ultrasonic sensor. Through Eagle I designed both plates, both with the Attiny45.</p>
                <div class="text-center">
                   <div class="section-title center" >
                      <h4><strong>What is an input device?</strong></h4>
                        <div class="line">
                          <hr>
                        </div>
                    </div>
                </div>
                <p>
                  An input device is any hardware device that sends data to a computer, allowing you to interact with and control it.<br/>
                  (1) Light Sensors: Light Dependent Resistor<br/>
                  Analog sensors that are used for detecting the amount of light striking the sensors are called as light sensors. These analog light sensors are again classified into various types such as photo-resistor, Cadmium Sulfide (CdS), and, photocell. Light dependent resistor (LDR) can be used as analog light sensor which can be used to switch on and off loads automatically based on the day light incident on the LDR. The resistance of the LDR increases with decrease in light and decreases with increase in light.<br/>
                  (2) HC-SR04 Sensor Features<br/>
                  Ultrasonic sensor is also known as Sonar sensor. Basically, Ultrasonic sensor is a device which is used to measure distance to an object. This works by sending out a wave which comes back by striking an object, it measures the time elapsed from generating of the wave to bounce back. This way it measures distance from the origin position of the sensor to the object. It follows the given below formula to calculate the distance.
                </p>
            <div class="text-center">
              <div class="section-title center" >
                <h4><strong>Hello.HC-SR04.45</strong></h4>
              </div>
            </div>
                <p>
                  ⑴ Eagl<br/>
                  I used eagle to start getting my board designed. The first thing I did was create a new project named “Input Devices”. I decided to make it just with the components that Neil did without adding extra (using ATtiny45). I used Eagle to redesign the same ultrasonic sensor. The necessary components for producing the board are the following:<br/>
                  <ul class="about-list" class="pull-left">
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                           - <em>1x ATtiny45</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x 10kΩ resistor</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x 1μF capacitor</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x 2x3 pin ISP header</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x1x4 pin header (HC-SR04 sensor)</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x 1x6 pin male connector (FTDI)</em>
                      </li>
                  </ul>
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture01.jpg" class="img-responsive" alt="..."></p><br/>
                <p style="text-align:center"><img src="img/week_09/Picture02.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  ⑵ PCB Production<br/>
                  I used the Roland SRM-20 milling machine, controlled with mods to mill the board, following the same process as in Electronics Design week.
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture03.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  (3) Programing<br/>
                  I encountered a lot of problem with synchronization on the ATtiny when programmed with the Arduino UNO and Arduino IDE. There is a problem I had which is it only showed “?????” on the serial monito. The conditions are the baud rate was 9600, programming at 1Mhz or 8MHz. Then I set the baud rate was 19200, 4800, 2400,1200, 38400. I didn't know why. I think it might have something to do with the clock.
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture04.jpg" class="img-responsive" alt="..."></p><br/>
                <p style="text-align:center"><img src="img/week_09/Picture05.jpg" class="img-responsive" alt="..."></p><br/>
                <p>Then I made another board of HC-SR04 and programing in the same way. It worked.</p>
                <p style="text-align:center"><img src="img/week_09/Picture06.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  ⑷ Testing<br/>
                  <iframe width="864" height="684" src="https://www.youtube.com/embed/KKOMKLjJvjI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br/>
                  <br/>
                  <br/>
                  <iframe width="1280" height="721" src="https://www.youtube.com/embed/AHRPIlziznI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                </p>
            <div class="text-center">
              <div class="section-title center" >
                <h4><strong>hello. light.45</strong></h4>
              </div>
            </div>
                <p>
                  (1) Eagle<br/>
                  I used Neil's design for the temperature sensor board "hello.temp.45". The board is shown below:
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture07.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  The necessary components for producing the board are the following:<br/>
                  <ul class="about-list" class="pull-left">
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                           - <em>1x ATtiny45</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>2x 10kΩ resistor</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x 1μF capacitor</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x 2x3 pin ISP header</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x 1x6 pin male connector (FTDI)</em>
                      </li>
                      <li>
                          <span class="fa fa-dot-circle-o"></span>
                          - <em>1x Photoresistor 1206</em>
                      </li>
                  </ul>
                  Then I used Eagle as usual to design my board. I used the Neil’s board as a reference for me.
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture08.jpg" class="img-responsive" alt="..."></p><br/>
                <p style="text-align:center"><img src="img/week_09/Picture09.jpg" class="img-responsive" alt="..."></p><br/>
                <p>Then I export the images from Eagle with 1500 resolution.</p>
                <p style="text-align:center"><img src="img/week_09/Picture10.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  (2) Fabricate my board<br/>
                  I usually used one offset to make sure of all traces will mills.
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture11.jpg" class="img-responsive" alt="..."></p><br/>
                <p>Weld and Programming the microcontroller ‘ATtiny 45’.</p>
                <p style="text-align:center"><img src="img/week_09/Picture12.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  ⑶ Programming<br/>
                  For this step we need to program the sensor PCB, Actually I used the Neil’s Code without any changes. I used the USBtiny board to program my board. I used an FTDI cable (5V) to connect my board with my computer and an ISP cable to connect the board with the USBtiny programmer. Then I used the make file that Neil shared in the lecture.
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture13.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  Then, we open command prompt in the directory that we downloaded the files in, and Write<br/>
                  <code>make -f hello. light.45. make program-USBtiny</code><br/>
                  1) - f to select the file that we need to maker<br/>
                  2) hello. light.45. make … we have to write the exactly name file without any changes<br/>
                  3) program-USBtiny … the exactly function we need to do
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture14.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  Then, I need to write this line<br/>
                  <code>avrdude -p t45 -P usb -c USBtiny -U flash: w: hello.light.45.c.hex</code><br/>
                  1) -p to specify the type of avrdude ‘t45’, attiny45<br/>
                  2) -p to specify the connection port … usb<br/>
                  3) -c to select the programmer ‘usbtiny’<br/>
                  4)-U to specify the memory operation
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture15.jpg" class="img-responsive" alt="..."></p><br/>
                <p>
                  ⑷ Testing<br/>
                  This step I also used the Neil’s Code without any changes. Then I need to write this line:<br/>
                  <code>python hello.light.45.py COM3</code><br/>
                  But there are some mistakes.
                </p>
                <p style="text-align:center"><img src="img/week_09/Picture16.jpg" class="img-responsive" alt="..."></p><br/>
                <p style="text-align:center"><img src="img/week_09/Picture17.jpg" class="img-responsive" alt="..."></p><br/>
                <p>Therefore, I performed serial port reading and programming in arduino by myself. The program is as follows.</p>
                <p style="text-align:center"><img src="img/week_09/Picture18.jpg" class="img-responsive" alt="..."></p><br/>
                <p>Then I test it and it worked.</p>
                <p>
                  <iframe width="864" height="486" src="https://www.youtube.com/embed/UFCQmstwAHc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                </p>
                <div class="text-center">
                   <div class="section-title center" >
                      <h2><strong>Group assignment</strong></h2>
                        <div class="line">
                          <hr>
                        </div>
                    </div>
                  </div>
                  <p>I used a universal digital meter to measure the voltage of the photosensitive resistance and found that the voltage decreases as the illumination increases.</p>
                  <iframe width="1274" height="721" src="https://www.youtube.com/embed/5N53PyEdIEk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                    <div class="text-center">
                       <div class="section-title center" >
                          <h2><strong>File Download</strong></h2>
                            <div class="line">
                              <hr>
                            </div>
                        </div>
                      </div>
                        <p> <a target=“_blank” href="Files/week_09/hello light 45.rar">hello light 45</a> </p>
                        <p> <a target=“_blank” href="Files/week_09/Hello.HC-SR04.rar">Hello.HC-SR04</a> </p>
        </div>
    </div>
  <!-- Testimonials Section
    ==========================================-->
    <div id="tf-testimonials" class="text-center">
        <div class="overlay">
            <div class="container">
                <div class="section-title center">
                  <div class="section-title center">
                      <h2><strong>contact Me</strong></h2>
                      <div class="line">
                          <hr>
                      </div>
                      <div class="clearfix"></div>
                      <small><em>
                        Address: No.10, Kehua street, Wuhou District, Chengdu, Sichuan Province, China<br />
                        TEL: (028) 85406538    (+86)18981085882<br />
                        E-mail: linzihao@scuspark.com<br />
                        QQ: 386866966
                      </em></small>
                  </div>

                  <form>
                      <div class="row">
                          <div class="col-md-6">
                              <div class="form-group">
                                  <label for="exampleInputEmail1">Email address</label>
                                  <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
                              </div>
                          </div>
                          <div class="col-md-6">
                              <div class="form-group">
                                  <label for="exampleInputPassword1">Password</label>
                                  <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
                              </div>
                          </div>
                      </div>
                      <div class="form-group">
                          <label for="exampleInputEmail1">Message</label>
                          <textarea class="form-control" rows="3"></textarea>
                      </div>

                      <button type="submit" class="btn tf-btn btn-default">Submit</button>
                  </form>
                </div>
            </div>
        </div>
    </div>

    <nav id="footer">
        <div class="container">
            <div class="pull-left fnav">
                <p>Science Park of Sichuan University Co.Ltd. All rights reserved. © 2020. Designed by Lin Zihao</p>
            </div>
            <div class="pull-right fnav">
                <ul class="footer-social">
                    <li><a href="https://www.facebook.com/zihao.lin.7399"><i class="fa fa-facebook"></i></a></li>
                    <li><a href="#"><i class="fa fa-dribbble"></i></a></li>
                    <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                    <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                </ul>
            </div>
        </div>
    </nav>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.1.11.1.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="js/SmoothScroll.js"></script>
    <script type="text/javascript" src="js/jquery.isotope.js"></script>

    <script src="js/owl.carousel.js"></script>

    <!-- Javascripts
    ================================================== -->
    <script type="text/javascript" src="js/main.js"></script>

  </body>
</html>