<!DOCTYPE HTML> <!-- Phantom by HTML5 UP html5up.net | @ajlkn Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) --> <html> <head> <title>SAMDino</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <link rel="stylesheet" href="assets/css/main.css" /> <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-5D374P6VHY"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-5D374P6VHY'); </script> </head> <body class="is-preload"> <!-- Wrapper --> <div id="wrapper"> <!-- Header --> <header id="header"> <div class="inner"> <!-- Logo --> <a href="index.html" class="logo"> <span class="symbol"><img src="images/LOGO%20fablab.png" alt="" /></span><span class="title">Adrián Torres</span> </a> <!-- Nav --> <nav> <ul> <li><a href="#menu">Menu</a></li> </ul> </nav> </div> </header> <!-- Menu --> <nav id="menu"> <h2>Menu</h2> <ul> <li><a href="index.html">Home</a></li> <li><a href="assignments.html">Assignments</a></li> <li><a href="project.html">Final Project</a></li> <li><a href="adrianino.html">Adrianino</a></li> <li><a href="samdino.html">SAMDino</a></li> <li><a href="about.html">About me</a></li> </ul> </nav> <!-- Main --> <div id="main"> <div class="inner"> <span class="image main"><img src="images/samdino/s_01.jpg" alt="" /></span> <h1>Index</h1> <ul class="actions"> <li><a href="#introduction" class="button primary">Introduction</a></li> <li><a href="#features" class="button primary">Features</a></li> <li><a href="#datasheet" class="button primary">Datasheet</a></li> <li><a href="#freedap" class="button primary">SAMD11C Free Dap Programmer</a></li></ul> <ul class="actions"><li><a href="#programming" class="button primary">Programming</a></li> <li><a href="#bom" class="button primary">BOM and Schematic</a></li> <li><a href="#board" class="button primary">Board design</a></li></ul> <ul class="actions"> <li><a href="#inputs" class="button primary">Inputs</a></li> <li><a href="#button" class="button">Button</a></li> <li><a href="#pir" class="button">Pyroelectric</a></li> <li><a href="#radar" class="button">Doppler radar</a></li> <li><a href="#ultrasonic" class="button">Ultrasonic sensor</a></li> </ul> <ul class="actions"><li><a href="#hall" class="button">Hall effect</a></li> <li><a href="#temperature" class="button">Temperature</a></li> <li><a href="#photo" class="button">Phototransistor</a></li> <li><a href="#photoir" class="button">Phototransistor IR</a></li> </ul> <ul class="actions"><li><a href="#step" class="button">Step Response</a></li></ul> <!-- <ul class="actions"> <li><a href="#flight" class="button">Time of flight</a></li> </ul> --> <ul class="actions"> <li><a href="#outputs" class="button primary">Outputs</a></li> <li><a href="#rgb" class="button">RGB LED</a></li> <li><a href="#motor" class="button">DC Motor</a></li> <li><a href="#servo" class="button">Servo motor</a></li> </ul> <!-- <li><a href="#lcd" class="button">LCD</a></li> <li><a href="#oled" class="button">OLED</a></li> </ul> --> <ul class="actions"> <li><a href="#conclusions" class="button primary">Conclusions</a></li> <li><a href="#files" class="button primary">Files</a></li> </ul> <h1><a id="introduction"></a>Introduction</h1> <p>During my Fab Academy I worked with the new ATtiny, the ATtiny412, ATtiny1614 and the ATtiny3216. But as a novelty this year there were also the new ARM microcontrollers with JTAG such as the SAMD11.</p> <p>For this I want to document on this page, the process of creating the programmer, as well as the SAMDino board that is similar to the Adrianino where you can connect different sensors or actuators and go testing to continue working on the <a href="https://gitlab.fabcloud.org/pub/helloworld/index"><b>Hello World project.</b></a></p> <p>To carry out the following project and the documentation I have consulted the documentation of <a href="http://fabacademy.org/2020/labs/ulb/students/quentin-bolsee/"><b>Quentin Bolsee</b></a> and <a href="http://fabacademy.org/2020/labs/agrilab/students/florent-lemaire/"><b>Florent Lemaire,</b></a> as well as the advice of the instructor <a href="http://archive.fabacademy.org/2018/labs/fablabulb/students/nicolas-decoster/index.html"><b>Nicolas De Coster.</b></a> Thank you. 🤗 </p> <p><img src="images/samdino/s_00.jpg" width="80%"; max-width="700" /></p> <h1><a id="features"></a>Features</h1> <ul><li> Via <b>USB</b> you can directly program and read data from a sensor. <li> It contains a voltage regulator to power the board with a <b>power supply</b> (9V battery). <li> It has another 9V power connection to for example power a DC motor driver. <li> Then there are 4 outputs or inputs with VCC and GND on each side to be able to connect different inputs or outputs. <li> On the left there is an <b>I2C</b> connection to connect an LCD, OLED or a sensor that uses this communication. <b>Working in progress.</b> Still not working. <li> There is an LED and an integrated button, which will help us to test that the microcontroller works with a simple program. <li> Possibility of connection with the <a href="adrianino.html"><b>Adrianino</b></a> input and output modules. </ul> <h1><a id="datasheet"></a>Datasheet</h1> <h2>SAM D11C 14A</h2> <p>A new generation of Atmel microcontrollers with SAMDs. A low-power, high-performance ARM® Cortex®-M0 + based flash microcontroller and with a full-speed USB device.</p> <ul><li><b>14 pin</b> package. <li>Internal and external clock options with 48MHDigital Frequency Locked Loop (DFLL48M) and 48MHto 96MHFractional. <li>16 KB Flash Memory. <li>256 B EEPROM. <li>4 KB SRAM. <li>Maximum voltage: <b>3.63 V</b>; minimum voltage:<b> 1.62 V.</b> </ul> <p>After looking at the basic features, you will find the pinning of the microcontroller. More information in this <a href="https://github.com/mattairtech/ArduinoCore-samd/tree/master/variants/Generic_D11C14A"><b>link. </b></a></p> <span class="image main"><img src="images/samdino/s_02.jpg" alt="" /></span> <ul><li><b>VDD:</b> Supply voltage. <li><b>GND:</b> Ground. <li><b>Digital pins:</b> PA02, PA04, PA05, PA08, PA09, PA14, PA15, PA31. <li><b>Analog pins:</b> PA02, PA04, PA05, PA14, PA15. <li><b>USB pins:</b> PA24, PA25.</ul> <p>All I/O pins can be configured with <b>internal pull up or pull down resistance.</b></p> <p>Within the communications section there are different types and their pins are different. It is clear that the different communication protocols cannot all be used at the same time, because they have pins in common.</p> <ul><li><b>USART - Universal Synchronous and Asynchronous Receiver and Transmitter: </b> It has the <b>RX</b> (PA31 or PA05) and the <b>TX</b> (PA30 or PA04). <li><b>SPI - Serial Peripheral Interface:</b> It has only <b>MOSI</b> (PA04 or PA08), <b>MISO</b> (PA14 or PA30), <b>SCK</b> (PA09), <b>SS</b> (PA15) . <li><b>TWI - Two Wire Interface (I2C):</b> It has <b>SDA</b> (PA14) and <b>SCL</b> (PA15). </ul> <p>Another important thing that the datasheet is telling us is that you have to keep in mind which kind of input component you are using, digital or analog: for instance, if you are using a temperature sensor (analog component) you have to connect it to an ACD (analog to digital converter) port otherwise the microcontroller isn't able to transform the information that is receiving from the sensor to a digital data.</p> <h1><a id="freedap"></a>SAMD11C Free Dap Programmer.</h1> <p>To work with this type of microcontrollers we need a programmer with <b>JTAG.</b> For this we can use the <a href="https://www.microchip.com/DevelopmentTools/ProductDetails/ATATMEL-ICE"><b>Atmel-ICE</b></a> or the <a href="https://store.particle.io/products/particle-debugger"><b>Particle.</b></a> But the ideal is to create a Free Dap programmer using a SAMD11C.</p> <p>Following Neil's documentation on the <a href=""><b>Embedded Programming</b></a> class we will find two types of programmers, the <a href="http://academy.cba.mit.edu/classes/embedded_programming/SWD/hello.CMSIS-DAP.10.D11C.png"><b>hello.CMSIS-DAP.10.D11C</b></a> and the <a href="http://academy.cba.mit.edu/classes/embedded_programming/SWD/hello.CMSIS-DAP.4.D11C.png"><b>hello.CMSIS-DAP.4.D11C.</b></a> In my case I will use the latter together with the <a href="http://academy.cba.mit.edu/classes/embedded_programming/SWD/hello.SWD.10-4.png"><b>hello.SWD.10-4 converter.</b></a></p> <p><img src="images/samdino/s_03.jpg" width="60%"; max-width="700" /></p> <p>Here you can see the boards already milled. IMPORTANT: remember to remove the excess copper around the USB, you could produce a short circuit. The other image with the BOM prepared.</p> <span class="image main"><img src="images/samdino/s_04.jpg" alt="" /></span> <p>Once all the components have been soldered, I have created a <a href="assignments/samdino/carcasa_samd.stl"><b>3D case</b></a> to make a better connection of the USB and I have also painted the red color for VCC and the white color for GND on the 1.27 mm SMD connectors. So when connecting flat cables there is no confusion.</p> <p><img src="images/samdino/s_07.jpg" width="60%"; max-width="700" /></p> <h1><a id="programming"></a>Programming</h1> <h2>Create a SAMD11C Free Dap Programmer. (Windows)</h2> <p>As I mentioned in the previous step, one of the advantages of this microcontroller is that we can turn it into a <b>programmer.</b> For this we need <a href="https://www.microchip.com/DevelopmentTools/ProductDetails/ATATMEL-ICE"><b>Atmel-ICE</b></a> or <a href="https://store.particle.io/products/particle-debugger"><b>Particle</b></a> programmer. In my case I use the Particle.</p> <p><img src="images/samdino/s_08.jpg" width="60%"; max-width="700" /></p> <p>We will connect the flat cables in the following way, from the Particle to the 10-4 converter, then with the 4-wire flat cable (in my case, 6-wire) to the future programmer.</p> <span class="image main"><img src="images/samdino/s_09.jpg" alt="" /></span> <p><b>IMPORTANT:</b> We will connect the Particle or the programmer to the computer and our Free Dap Programmer to an external power supply (that is not the same computer).</p> <ul><li><b>1.</b> We will download the <a href="https://github.com/ataradov/edbg"><b>EDBG,</b></a> in my case I download the <a href="https://dl.bintray.com/ataradov/edbg/master/"><b>B74 version. The version is important when executing the installation.</b></a></li></ul> <p><img src="images/samdino/s_10.jpg" width="80%"; max-width="700" /></p> <ul><li><b>2.</b> Then on the <b>Fab Academy</b> page (Embedded Programming) we will find the Free Dap bootloader that we will also <a href="http://academy.cba.mit.edu/classes/embedded_programming/SWD/free_dap_d11c_mini.bin"><b>download.</b></a> </li></ul> <p><img src="images/samdino/s_11.jpg" width="80%"; max-width="700" /></p> <ul><li><b>3. Open terminal.</b> We execute inside the EDBG folder <b><i>edbg-b74-WINDOWS-7029fc4.exe -bpv -t samd11 -f free_dap_d11c_mini.bin </i></b> The LED of our programmer should light up and appear on our screen like the following capture.</ul> <p><img src="images/samdino/s_12.jpg" width="80%"; max-width="700" /></p> <p>With this programming we get a programmer, now we can program other SAMD11C and have our own programmer or for the Fab Lab. This would be the connection, remember to feed the programmer to the computer and the future programmer to an external power source. Then we repeat the previous steps and program it.</p> <p><img src="images/samdino/s_13.jpg" width="80%"; max-width="700" /></p> <h2>SAM11C with Arduino</h2> <p>Once we have the SAMD11C as a Free Dap programmer, we can change the bootloader so that we can program the SAMD11C through the Arduino IDE. For this we will follow the following steps. You can find more information on the <a href="https://github.com/mattairtech/ArduinoCore-samd"><b>Mattairtech Git Hub.</b></a></p> <ul><li><b>1.</b> We will <a href="https://github.com/mattairtech/ArduinoCore-samd/blob/master/bootloaders/zero/binaries/sam_ba_Generic_D11C14A_SAMD11C14A.bin"><b>download</b></a> the sam_ba_Generic_D11C14A bootloader.</li> <li><b>2. Open terminal.</b> We execute inside the EDBG folder <b><i>edbg-b74-WINDOWS-7029fc4.exe -bpv -e -t samd11 -f sam_ba_Generic_D11C14A_SAMD11C14A.bin </i></b> Appear on our screen like the following capture.</ul> <p><img src="images/samdino/s_14.jpg" width="80%"; max-width="700" /></p> <ul><li><b>3.</b> We open the Arduino program. <li><b>4.</b> In Preferences, we will add the URL of the additional cards that you can find <a href="https://www.mattairtech.com/software/arduino/package_MattairTech_index.json"><b>here.</b></a> We need the <a href="https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls"><b>MattairTech LLC.</b></a></ul> <p><img src="images/samdino/s_15.jpg" width="50%"; max-width="700" /></p> <ul><li><b>5.</b> The next step is to download Generic SAMD11C in the boards manager.</ul> <p><img src="images/samdino/s_16.jpg" width="50%"; max-width="700" /></p> <ul><li><b>6.</b> We configure the Arduino IDE for the SAMD11C. The SAMD11C will appear in the COM port, in my case in COM 8.</ul> <p><img src="images/samdino/s_17.jpg" width="80%"; max-width="700" /></p> <ul><li><b>7.</b> Now load the Blink program so that the LED on pin 14 blinks. When we upload it, all this information appears in the notifications section.</ul> <p><img src="images/samdino/s_18.jpg" width="80%"; max-width="700" /></p> <p>In this short video you can see the operation of a Blink on pin PA14 (14 in Arduino) where the LED is integrated. 😍 </p> <p><video controls width="100%"; max-width="800"><source src="images/samdino/blink1.mp4" type="video/mp4"></video></p> <h1><a id="bom"></a>BOM and Schematic for SAMDino</h1> <p>This is the schematic where you can see all the components.</p> <p><img src="images/samdino/s_05.jpg" width="80%"; max-width="700" /></p> <style> table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; } tr:nth-child(even) { background-color: #dddddd; } </style> <table> <tr> <td><h3><b>Samdino</b></h3></td> <td>Where to buy?</td> <td>Amount</td> <td>Price</td> <td>Total price</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/bantam-tools/MT1004/1932-1038-ND/8567212">Proto Board FR1</a></td> <td>Digikey</td> <td>1/4 board</td> <td>1,24 €/unit</td> <td>0,31 €</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/microchip-technology/ATSAMD11C14A-SSNT/ATSAMD11C14A-SSNTCT-ND/5956608">SAMD11C 14A</a></td> <td>Digikey</td> <td>1</td> <td>1,01 €/unit</td> <td>1,01 €</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/samsung-electro-mechanics/CL31F105ZBFNNNE/1276-1204-1-ND/3889290">1uF capacitor 50V</a></td> <td>Digikey</td> <td>2</td> <td>0,18 €/unit</td> <td>0,36 €</td> </tr> <tr> <td><a href="https://www.digikey.es/products/es?keywords=311-4.99KFRCT-ND">4,99kΩ resistor</a></td> <td>Digikey</td> <td>2</td> <td>0,09 €/unit</td> <td>0,18 €</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/yageo/RC1206FR-07499RL/311-499FRCT-ND/731891">499 Ω resistor</a></td> <td>Digikey</td> <td>1</td> <td>0,09 €/unit</td> <td>0,09 €</td> </tr> <tr> <td><a href="https://www.digikey.com/en/products/detail/texas-instruments/LM2940IMP-5-0-NOPB/270714">IC Regulator 5V 1A SOT223</a></td> <td>Digikey</td> <td>1</td> <td>0,43 €/unit</td> <td>0,43 €</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/texas-instruments/LM3480IM3-3.3-NOPB/LM3480IM3-3.3-NOPBCT-ND/270750">IC Regulator 3.3V 100MA SOT23-3</a></td> <td>Digikey</td> <td>1</td> <td>0,84 €/unit</td> <td>0,84 €</td> </tr> <tr> <td><a href="https://www.digikey.es/products/es?keywords=311-1.00KFRCT-ND">1kΩ resistor</a></td> <td>Digikey</td> <td>1</td> <td>0,09 €/unit</td> <td>0,09 €</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/susumu/RGV3216P-9103-B-T1/408-RGV3216P-9103-B-T1CT-ND/13180887">10kΩ resistor</a></td> <td>Digikey</td> <td>1</td> <td>0,62 €/unit</td> <td>0,62 €</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/lite-on-inc/LTST-C150TBKT/160-1643-1-ND/573584">LED</a></td> <td>Digikey</td> <td>1</td> <td>0,35 €/unit</td> <td>0,35 €</td> </tr> <tr> <td><a href="https://www.digikey.com/product-detail/es/omron-electronics-inc-emc-div/B3SN-3112P/SW262CT-ND/60835">Button</a></td> <td>Digikey</td> <td>1</td> <td>1,00 €/unit</td> <td>1,00 €</td> </tr> <tr> <td><a href="https://www.digikey.com/product-detail/es/gct/BG300-02-A-L-A/2073-BG300-02-A-L-ACT-ND/9859663">Female 1 row horizontal header</a></td> <td>Digikey</td> <td>14</td> <td>0,15 €/unit</td> <td>2,10 €</td> </tr> <tr> <td><a href="https://www.digikey.es/product-detail/es/sullins-connector-solutions/GRPB022VWQS-RC/S9012E-02-ND/1786411"> Connector Header SMD 4POS 1.27mm</a></td> <td>Digikey</td> <td>1</td> <td>0,39 €/unit</td> <td>0,39 €</td> </tr> <tr> <td></td> <td></td> <td></td> <td><b>Total cost</b></td> <td><b>7,77 €</b></td> </tr> </table> <h1><a id="board"></a>Board design</h1> <p>Here you can download the Eagle files and the PNG's. Here is a sample of the PNG's, traces and cutting lines.</p> <ul><li><a href="assignments/samdino/samdino.zip"><b>SAMDino Schematic + Board</b></a> <li><a href="assignments/samdino/samdino_traces.png"><b>SAMDino Traces</b></a> <li><a href="assignments/samdino/samdino_interior.png"><b>SAMDino Interior</b></a></ul> <span class="image main"><img src="images/samdino/s_06.jpg" alt="" /></span> <h1><a id="inputs"></a>Inputs</h1> <h2><a id="button"></a>Button</h2> <p>The button is the simplest element of the inputs. It is an open or closed contact that when we press it changes its state to closed or open.</p> <li><b>Connection and schematic</b></li> <p>In this case, the button is integrated on the board, on the PA04 pin (Arduino pin 4) and the LED on the PA02 pin (Arduino pin 2).</p> <p><img src="images/samdino/s_19.jpg" width="60%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use the button. Here you can find the Arduino file to download.</p> <p><a href="assignments/samdino/button_led/button_led.ino"><b>- Arduino Hello Button</b></a> <pre><code>//Fab Academy 2020 - Fab Lab León //Button + LED //SAMDino //SAMD11C // //Original code:Neil Gershenfeld 12/8/19 // This work may be reproduced, modified, distributed, // performed, and displayed for any purpose, but must // acknowledge this project. Copyright is retained and // must be preserved. The work is provided as is; no // warranty is provided, and users accept all liability. // const int ledPin1 = 2;//first light const int buttonPin = 4;// button pin int buttonState = 0;//initial state of the button int i = 0; //variable intensity led void setup() { //declaration of inputs and outputs pinMode(ledPin1, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin);// we read the state of the button if (buttonState == HIGH) { //if we press the button digitalWrite(ledPin1, HIGH); delay(500); digitalWrite(ledPin1, LOW); delay(500); digitalWrite(ledPin1, HIGH); delay(500); digitalWrite(ledPin1, LOW); delay(500); digitalWrite(ledPin1, HIGH); delay(2000); digitalWrite(ledPin1, LOW); delay(1000); } else { //if we don't press the button digitalWrite(ledPin1, LOW); } }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/button1.mp4" type="video/mp4"></video></p> <h2><a id="pir"></a>Pyroelectric</h2> <p>A passive infrared sensor (or PIR sensor) is an electronic sensor that measures infrared (IR) light radiated from objects in its field of view. They are mainly used in PIR-based motion detectors.</p> <li><b>Connection and schematic</b></li> <p>In this case we only need three cables; one for <b>VCC</b> to 5V, another for <b>GND</b> and another for the sensor output that in our case we will connect it to pin <b>PA05</b> (5 in Arduino). I also use the LED that is on <b>PA02</b> (Arduino pin 2).</p> <span class="image main"><img src="images/samdino/s_28.jpg" alt="" /></span> <li><b>Programming</b></li> <p>Here you will find the programming to use a digital sensor such as the PIR. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/samdino/hello_pir/hello_pir.ino"><b>- Arduino Hello PIR</b></a> <p><a href="assignments/adrianino/radar_pir_processing/radar_pir_processing.pde"><b>- Processing Hello PIR</b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //PIR sensor //SAMDino //SAMD11C //Original code by Luis Llamas. const int LEDPin = 2; // for LED const int PIRPin = 5; // for PIR sensor int pirState = LOW; // start there is no movement int val = 0; // pin status void setup() { pinMode(LEDPin, OUTPUT); pinMode(PIRPin, INPUT); Serial.begin(115200); } void loop() { val = digitalRead(PIRPin); if (val == HIGH) //if activated { digitalWrite(LEDPin, HIGH); //LED ON if (pirState == LOW) { Serial.println("1"); pirState = HIGH; } } else //is not activated { digitalWrite(LEDPin, LOW); // LED OFF if (pirState == HIGH) //si { Serial.println("0"); pirState = LOW; } } }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/pir1.mp4" type="video/mp4"></video></p> <h2><a id="radar"></a>Doppler radar</h2> <p>The <b>RCWL-0516</b> is a Dopler Microwave Radar Sensor.It is an alternative to traditional PIR infrared motion detectors. Faced with these, it has certain differences, which will be an advantage or disadvantage depending on the needs of our project.</p> <p>First of all, PIR sensors require the moving object to have a temperature difference from the environment. For this reason, they are able to detect people, but not moving objects. In contrast, the RCWL-0516 detects any object that is moving, regardless of its temperature. On the other hand, PIR sensors have sensitivity problems when the ambient temperature is high. The RCWL-0516, on the other hand, does not have this problem and works correctly between <b>-20ºC to 80ºC.</b> In terms of detection range, the RCWL-0516 has a greater range than PIR sensors, being able to easily reach <b>5-7 meters of range.</b> </p> <p>Finally, the RCWL-0516 is omnidirectional, that is, it detects movement in <b>360º.</b> This is a difference from PIR sensors, which have a certain "angle of view". There are even versions of PIR with a narrow beam, for example to control windows or doors.</p> <li><b>Connection and schematic</b></li> <p>In this case we only need three cables; one for <b>VCC</b>, another for <b>GND</b> and another for the sensor output that in our case we will connect it to pin <b>PA04</b> (4 in Arduino). <b>IMPORTANT:</b> connect the VCC to 5V.</p> <span class="image main"><img src="images/samdino/s_22.jpg" alt="" /></span> <li><b>Programming</b></li> <p>Here you will find the programming to use a digital sensor such as the PIR. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/samdino/hello_pir_radar/hello_pir_radar.ino"><b>- Arduino Hello Radar</b></a> <p><a href="assignments/adrianino/radar_pir_processing/radar_pir_processing.pde"><b>- Processing Hello Radar</b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //Doppler radar //SAMDino //SAMD11C const int RadarPin = 4; // digital input pin to hook the sensor to int value = 6; // variable to store the value coming from the sensor void setup() { Serial.begin(115200); // initialize serial communications pinMode(RadarPin, INPUT); //digital input pin } void loop() { int value= digitalRead(RadarPin); // read the value from the sensor (0 or 1) Serial.println(value); // print value to Serial Monitor }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/radar1.mp4" type="video/mp4"></video></p> <h2><a id="ultrasonic"></a>Ultrasonic sensor</h2> <p>The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. It comes complete with ultrasonic transmitter and receiver modules.</p> <li><b>Connection and schematic</b></li> <p>In this case we only need four cables; one for <b>VCC</b> to 5V, one for <b>GND</b>, another cable for the Trigger (PA05, Arduino pin 5) and another for the Echo (PA04, Arduino pin 4).</p> <span class="image main"><img src="images/samdino/s_25.jpg" alt="" /></span> <li><b>Programming</b></li> <p>Here you will find the programming to use a digital sensor such as the Ultrasonic sensor. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/samdino/hello_ultrasonic/hello_ultrasonic.ino"><b>- Arduino Hello Ultrasonic sensor</b></a> <p><a href="assignments/adrianino/ultrasonic_processing/ultrasonic_processing.pde"><b>- Processing Hello Ultrasonic sensor</b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //Ultrasonic sensor //SAMDino //SAMD11C const int EchoPin = 4; const int TriggerPin = 5; void setup() { Serial.begin(115200); pinMode(TriggerPin, OUTPUT); pinMode(EchoPin, INPUT); } void loop() { int cm = ping(TriggerPin, EchoPin); Serial.print(""); Serial.println(cm); delay(1000); } int ping(int TriggerPin, int EchoPin) { long duration, distanceCm; digitalWrite(TriggerPin, LOW); //to generate a clean pulse we set LOW 4us delayMicroseconds(4); digitalWrite(TriggerPin, HIGH); //we generate Trigger (trigger) of 10us delayMicroseconds(10); digitalWrite(TriggerPin, LOW); duration = pulseIn(EchoPin, HIGH); //we measure the time between pulses, in microseconds distanceCm = duration * 10 / 292/ 2; //we convert distance, in cm return distanceCm; }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/ultrasonic1.mp4" type="video/mp4"></video></p> <h2><a id="hall"></a>Hall effect</h2> <p>The <a href="https://www.digikey.com/product-detail/en/A1324LLHLT-T/620-1402-1-ND/"><b>Hall effect</b></a> sensor or simply Hall sensor or Hall probe uses the Hall effect to measure magnetic fields or currents or to determine the position in which it is.</p> <li><b>Connection and schematic</b></li> <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the hall effect sensor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the ATtiny1614 PA4 (Arduino pin 0).</p> <span class="image main"><img src="images/samdino/s_27.jpg" alt="" /></span> <p>Here you can find the design in Eagle and the PNG's to create the board.</p> <p><a href="assignments/adrianino/hall_effect_eagle.zip"><b>- Hall effect Schematic + Board</b></a> <p><a href="assignments/adrianino/hall_effect_png.zip"><b>- Hall effect traces</b></a></p> <p><img src="images/adrianino/a_10.jpg" width="70%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use an analog sensor such as the Hall effect sensor. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/samdino/hello_hall/hello_hall.ino"><b>- Arduino Hello Hall effect sensor</b></a> <p><a href="assignments/adrianino/hall_effect_processing/hall_effect_processing.pde"><b>- Processing Hello Hall effect sensor</b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //Hall Effect //SAMDino //SAMD11C int sensorPin = 4; // analog input pin to hook the sensor to int sensorValue = 0; // variable to store the value coming from the sensor void setup() { Serial.begin(115200); // initialize serial communications } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor sensorValue = map(sensorValue, 290, 300, 0, 1024); Serial.println(sensorValue); // print value to Serial Monitor //mySerial.println("x"); // print value "x" to Serial Monitor delay(500); // short delay so we can actually see the numbers }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/hall1.mp4" type="video/mp4"></video></p> <h2><a id="temperature"></a>Temperature. NTC.</h2> <p>The <a href="https://www.digikey.com/product-detail/en/NHQ103B375T10/235-1109-1-ND"><b>NTC</b></a> sensor is a type of resistance whose value varies as a function of temperature in a more pronounced way than a common resistance. Its operation is based on the variation of the resistivity that a semiconductor presents with temperature.</p> <li><b>Connection and schematic</b></li> <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the NTC sensor, a 10K resistor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the SAMD11C PA04 (Arduino pin 4).</p> <span class="image main"><img src="images/samdino/s_24.jpg" alt="" /></span> <p>Here you can find the design in Eagle and the PNG's to create the board.</p> <p><a href="assignments/adrianino/temperature_eagle.zip"><b>- NTC Schematic + Board</b></a> <p><a href="assignments/adrianino/temperature_png.zip"><b>- NTC traces</b></a></p> <p><img src="images/adrianino/a_13.jpg" width="70%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use an analog sensor such as the NTC sensor. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/samdino/hello_ntc/hello_ntc.ino"><b>- Arduino Hello NTC Temperature sensor</b></a> <p><a href="assignments/adrianino/temperature_processing/temperature.pde"><b>- Processing Hello NTC Temperature sensor</b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //NTC sensor //SAMDino //SAMD11C int sensorPin = 4; // analog input pin to hook the sensor to int sensorValue = 0; // variable to store the value coming from the sensor void setup() { Serial.begin(115200); // initialize serial communications } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor sensorValue = map(sensorValue, 0, 85, 0, 40); Serial.println(sensorValue); // print value to Serial Monitor //mySerial.println("x"); // print value "x" to Serial Monitor delay(500); // short delay so we can actually see the numbers }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/temperature1.mp4" type="video/mp4"></video></p> <h2><a id="photo"></a>Phototransistor. Visible.</h2> <p>The <a href="https://www.digikey.com/product-detail/en/everlight-electronics-co-ltd/PT15-21C-TR8/1080-1380-1-ND"><b>Phototransistor</b></a> sensor is a three-layer semiconductor device which has a light-sensitive base region. The base senses the light and converts it into the current which flows between the collector and the emitter region.</p> <li><b>Connection and schematic</b></li> <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Phototransistor sensor, a 10K resistor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the SAMD11C PA04 (Arduino pin 4).</p> <span class="image main"><img src="images/samdino/s_23.jpg" alt="" /></span> <p>Here you can find the design in Eagle and the PNG's to create the board.</p> <p><a href="assignments/adrianino/phototransisor_eagle.zip"><b>- Phototransistor Schematic + Board</b></a> <p><a href="assignments/adrianino/phototransisor_png.zip"><b>- Phototransistor traces</b></a></p> <p><img src="images/adrianino/a_15.jpg" width="70%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use an analog sensor such as the Phototransistor sensor. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/samdino/hello_phototransistor/hello_phototransistor.ino"><b>- Arduino Hello Phototransistor sensor</b></a> <p><a href="assignments/adrianino/phototransitor_processing/phototransitor_processing.pde"><b>- Processing Hello Phototransistor sensor</b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //Phototransistor //SAMDino //SAMD11C int sensorPin = 4; // analog input pin to hook the sensor to int sensorValue = 0; // variable to store the value coming from the sensor void setup() { Serial.begin(115200); // initialize serial communications } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor sensorValue = map(sensorValue, 25, 50, 0, 1024); Serial.println(sensorValue); // print value to Serial Monitor //mySerial.println("x"); // print value "x" to Serial Monitor delay(500); // short delay so we can actually see the numbers }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/photo1.mp4" type="video/mp4"></video></p> <h2><a id="photoir"></a>Phototransistor. IR.</h2> <p>The <a href="https://www.digikey.com/product-detail/en/everlight-electronics-co-ltd/PT15-21B-TR8/1080-1379-1-ND"><b>Phototransistor IR</b></a> sensor is a three-layer semiconductor device which has a light-sensitive base region. The base senses the IR and converts it into the current which flows between the collector and the emitter region.</p> <li><b>Connection and schematic</b></li> <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Phototransistor IR sensor, a 10K resistor, a <a href="https://www.digikey.es/product-detail/es/everlight-electronics-co-ltd/IR15-21C-TR8/1080-1352-1-ND/2676086"><b>IR LED,</b></a> a 1K resistor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the SAMD11C PA04 (Arduino pin 4).</p> <span class="image main"><img src="images/samdino/s_26.jpg" alt="" /></span> <p>Here you can find the design in Eagle and the PNG's to create the board.</p> <p><a href="assignments/adrianino/phototransisor_IR_eagle.zip"><b>- Phototransistor IR Schematic + Board</b></a> <p><a href="assignments/adrianino/photo_ir_png.zip"><b>- Phototransistor IR traces</b></a></p> <p><img src="images/adrianino/a_23.jpg" width="70%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use an analog sensor such as the Phototransistor sensor. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/samdino/hello_phototransistor_ir/hello_phototransistor_ir.ino"><b>- Arduino Hello Phototransistor IR sensor</b></a> <p><a href="assignments/adrianino/photo_ir_processing/photo_ir_processing.pde"><b>- Processing Hello Phototransistor IR sensor</b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //Phototransistor IR //SAMDino //SAMD11C int sensorPin = 4; // analog input pin to hook the sensor to int sensorValue = 0; // variable to store the value coming from the sensor void setup() { Serial.begin(115200); // initialize serial communications } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor sensorValue = map(sensorValue, 40, 60, 0, 1024); Serial.println(sensorValue); // print value to Serial Monitor //mySerial.println("x"); // print value "x" to Serial Monitor delay(500); // short delay so we can actually see the numbers }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/photoir1.mp4" type="video/mp4"></video></p> <!-- <h2><a id="flight"></a>Time of flight</h2> <p>I use a module that integrates the <b>VL53L0X sensor.</b> The module is sold by <a href="https://learn.adafruit.com/adafruit-vl53l0x-micro-lidar-distance-sensor-breakout/overview"> <b>Adafruit,</b></a> although in my case I bought it from <a href="https://www.amazon.es/s?k=vl53l0x&__mk_es_ES=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=FRB5JPGJ2WSI&sprefix=vl%2Caps%2C169&ref=nb_sb_ss_i_1_2"> <b>Amazon.</b></a> In this case of the pinout that the sensor brings, I will only use the VCC, GND, SDA and SCL pins. This information is obtained from the <a href="https://www.luisllamas.es/arduino-sensor-distancia-vl53l0x/"> <b> Luis Llamas website.</b></a></p> <p><img src="images/week09/week09.17.jpg" width="60%"; max-width="700" /></p> <li><b>Connection and schematic</b></li> <p>In this case we only need four cables; one for <b>VCC</b>, one for <b>GND</b>, another cable for the <b>SDA</b> (PB1, Arduino pin 6) and another for the <b>SCL</b> (PB0, Arduino pin 7).</p> <p><img src="images/adrianino/a_18.jpg" width="70%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use the Time of Flight sensor. Here you can find the Arduino and Processing files to download.</p> <p><a href="assignments/week09/Single_VL53L0X/Single_VL53L0X.ino"><b>- Arduino Time of Flight sensor</b></a> <p><a href="assignments/adrianino/time_flight/time_flight.pde"><b>- Processing Time of Flight sensor </b></a></p> <pre><code>//Fab Academy 2020 - Fab Lab León //Time of Flight //Adrianino //ATtiny1614 /* This example shows how to get single-shot range measurements from the VL53L0X. The sensor can optionally be configured with different ranging profiles, as described in the VL53L0X API user manual, to get better performance for a certain application. This code is based on the four "SingleRanging" examples in the VL53L0X API. The range readings are in units of mm. */ #include Wire.h #include VL53L0X.h VL53L0X sensor; // Uncomment this line to use long range mode. This // increases the sensitivity of the sensor and extends its // potential range, but increases the likelihood of getting // an inaccurate reading because of reflections from objects // other than the intended target. It works best in dark // conditions. //#define LONG_RANGE // Uncomment ONE of these two lines to get // - higher speed at the cost of lower accuracy OR // - higher accuracy at the cost of lower speed //#define HIGH_SPEED //#define HIGH_ACCURACY void setup() { Serial.begin(115200); Wire.begin(); sensor.setTimeout(500); if (!sensor.init()) { Serial.println("Failed to detect and initialize sensor!"); while (1) {} } #if defined LONG_RANGE // lower the return signal rate limit (default is 0.25 MCPS) sensor.setSignalRateLimit(0.1); // increase laser pulse periods (defaults are 14 and 10 PCLKs) sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18); sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14); #endif #if defined HIGH_SPEED // reduce timing budget to 20 ms (default is about 33 ms) sensor.setMeasurementTimingBudget(20000); #elif defined HIGH_ACCURACY // increase timing budget to 200 ms sensor.setMeasurementTimingBudget(200000); #endif } void loop() { Serial.print(sensor.readRangeSingleMillimeters()); if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } Serial.println(); }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/adrianino/flight.mp4" type="video/mp4"></video></p> --> <h2><a id="step"></a>Step Response.</h2> <p>The step-response is a sensor that is made with two sheets of copper, separated from each other by a porous insulating material. It can be used to calculate the value of force, weight, resistance ... I have followed <a href="https://roberthart56.github.io/SCFAB/SC_lab/Sensors/tx_rx_sensors/index.html"><b>Robert Hart's tutorial</b></a> as well as <a href="http://academy.cba.mit.edu/classes/input_devices/step/hello.txrx.45.mp4"><b>Neil's examples.</b></a></p> <p>A series of pulses is sent through the TX electrode, which, depending on the material between the two electrodes, allows more or less that series of pulses to pass. In the following graph you can see how it works. The other electrode will be connected between two resistors, one for pull-up and the other for pull-down and to an analog input.</p> <p><img src="images/adrianino/a_38.jpg" width="70%"; max-width="700" /></p> <li><b>Connection and schematic</b></li> <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder two 1M resistors and with flat connectors where there is no room for errors when connecting it. I use the analog input from the SAMD11C PA05 (Arduino pin 5) for the RX and a digital output from the SAMD11C PA08 (Arduino pin 8). Then with a connector there are two cables that connect the two electrodes (<a href="https://www.3m.com/3M/en_US/company-us/all-3m-products/~/3M-Conductive-Copper-Foil-Tape-3313/?N=5002385+3293242553&rt=rud"><b>3M™ Copper Foil Tape</b></a>).</p> <span class="image main"><img src="images/adrianino/a_39.jpg" alt="" /></span> <p>Here you can find the design in Eagle and the PNG's to create the board.</p> <p><a href="assignments/adrianino/step_response_eagle.zip"><b>- Step Response Schematic + Board</b></a> <p><a href="assignments/adrianino/step_response_png.zip"><b>- Step Response traces</b></a></p> <p><img src="images/adrianino/a_40.png" width="50%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use a Step Response sensor. Here you can find the Arduino and Processing files to download. Below you can see a video of how it works.</p> <p><a href="assignments/adrianino/step_response_txrx/step_response_txrx.ino"><b>- Arduino Step Responde TX/RX</b></a> <p><a href="assignments/adrianino/step_response_processing/step_response.pde"><b>- Processing Step Response TX/RX</b></a></p> <pre><code>//tx_rx03 Robert Hart Mar 2019. //https://roberthart56.github.io/SCFAB/SC_lab/Sensors/tx_rx_sensors/index.html //Modified by Adrián Torres Omaña //Fab Academy 2021 //Step Response TX, RX //SAMDino //SAMD11C // Program to use transmit-receive across space between two conductors. // One conductor attached to digital pin, another to analog pin. // // This program has a function "tx_rx() which returns the value in a long integer. // // Optionally, two resistors (1 MOhm or greater) can be placed between 5V and GND, with // the signal connected between them so that the steady-state voltage is 2.5 Volts. // // Signal varies with electric field coupling between conductors, and can // be used to measure many things related to position, overlap, and intervening material // between the two conductors. // long result; //variable for the result of the tx_rx measurement. int analog_pin = 5; // PA05 of the SAMD11C int tx_pin = 8; // PA08 of the SAMD11C void setup() { pinMode(tx_pin,OUTPUT); //Pin 2 provides the voltage step Serial.begin(115200); } long tx_rx(){ //Function to execute rx_tx algorithm and return a value //that depends on coupling of two electrodes. //Value returned is a long integer. int read_high; int read_low; int diff; long int sum; int N_samples = 100; //Number of samples to take. Larger number slows it down, but reduces scatter. sum = 0; for (int i = 0; i < N_samples; i++){ digitalWrite(tx_pin,HIGH); //Step the voltage high on conductor 1. read_high = analogRead(analog_pin); //Measure response of conductor 2. delayMicroseconds(100); //Delay to reach steady state. digitalWrite(tx_pin,LOW); //Step the voltage to zero on conductor 1. read_low = analogRead(analog_pin); //Measure response of conductor 2. diff = read_high - read_low; //desired answer is the difference between high and low. sum += diff; //Sums up N_samples of these measurements. } return sum; } //End of tx_rx function. void loop() { result = tx_rx(); result = map(result, -400, 2000, 0, 1024); //I recommend mapping the values of the two copper plates, it will depend on their size Serial.println(result); delay(100); }</code></pre> <p>This first video you can see how the two electrodes work with several sheets as intermediate material.</p> <p><video controls width="100%"; max-width="800"><source src="images/adrianino/step1.mp4" type="video/mp4"></video></p> <p>In this second video you can see how it works with a sponge as an intermediate material.</p> <p><video controls width="100%"; max-width="800"><source src="images/adrianino/step2.mp4" type="video/mp4"></video></p> <h1><a id="outputs"></a>Outputs</h1> <h2><a id="rgb"></a>RGB LED</h2> <p>The <a href="https://www.digikey.com/product-detail/en/cree-inc/CLV1A-FKB-CK1VW1DE1BB7C3C3/CLV1A-FKB-CK1VW1DE1BB7C3C3CT-ND"><b>RGB LED</b></a> stands for Red, Blue and Green LEDs. RGB LED products combine these three colors to produce more than 16 million shades of light. </p> <li><b>Connection and schematic</b></li> <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the RGB LED, two 1K resistors (for red and green color), a 499 resistor (for blue color) and with the flat connectors where there is no room for mistakes when connecting it. I use the digitals ouputs of the SAMDino PA04 (Arduino pin 4), PA05 (Arduino pin 5), PA08 (Arduino pin 8).</p> <span class="image main"><img src="images/samdino/s_20.jpg" alt="" /></span> <p>Here you can find the design in Eagle and the PNG's to create the board.</p> <p><a href="assignments/adrianino/led_RGB_eagle.zip"><b>- RGB LED Schematic + Board</b></a> <p><a href="assignments/adrianino/led_rgb_png.zip"><b>- RGB LED traces</b></a></p> <p><img src="images/adrianino/a_25.jpg" width="70%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you will find the programming to use a RGB LED. Here you can find the Arduino file to download.</p> <p><a href="assignments/samdino/hello_rgb/hello_rgb.ino"><b>- Arduino Hello RGB LED</b></a> <pre><code>//Fab Academy 2020 - Fab Lab León //RGB LED //SAMDino //SAMD11C const byte COLOR_BLACK = 0b000; const byte COLOR_BLUE = 0b100; const byte COLOR_RED = 0b010; const byte COLOR_GREEN = 0b001; const byte COLOR_MAGENTA = 0b101; const byte COLOR_CYAN = 0b011; const byte COLOR_YELLOW = 0b110; const byte COLOR_WHITE = 0b111; const byte PIN_LED_R = 5; const byte PIN_LED_G = 8; const byte PIN_LED_B = 4; void setup() { pinMode(PIN_LED_R, OUTPUT); pinMode(PIN_LED_G, OUTPUT); pinMode(PIN_LED_B, OUTPUT); displayColor(COLOR_BLACK); } void loop() { displayColor(COLOR_RED); delay(1000); displayColor(COLOR_GREEN); delay(1000); displayColor(COLOR_BLUE); delay(1000); displayColor(COLOR_MAGENTA); delay(1000); displayColor(COLOR_CYAN); delay(1000); displayColor(COLOR_YELLOW); delay(1000); displayColor(COLOR_WHITE); delay(1000); displayColor(COLOR_BLACK); delay(1000); } void displayColor(byte color) { digitalWrite(PIN_LED_R, !bitRead(color, 0)); digitalWrite(PIN_LED_G, !bitRead(color, 2)); digitalWrite(PIN_LED_B, !bitRead(color, 1)); }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/rgb1.mp4" type="video/mp4"></video></p> <h2><a id="motor"></a>DC Motor</h2> <p>To control a DC motor we will use an H bridge, such as the <a href="https://www.digikey.com/product-detail/en/allegro-microsystems-llc/A4953ELJTR-T/620-1428-1-ND"><b>Allegro A4953.</b></a> With this driver we can control all types of motors through <b>PWM signals.</b> </p> <li><b>Connection and schematic</b></li> <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Allegro A4953 driver, a 1uF capacitor, a 10uF capacitor and with the flat connectors where there is no room for mistakes when connecting it. It includes two traces to feed with the 9V battery. I use two digital output of the SAMD11C PA04 (Arduino pin 4) and PA05 (Arduino pin 5).</p> <span class="image main"><img src="images/samdino/s_29.jpg" alt="" /></span> <p>Here you can find the design in Eagle and the PNG's to create the board.</p> <p><a href="assignments/adrianino/motor_eagle.zip"><b>- Motor Schematic + Board</b></a> <p><a href="assignments/adrianino/motor_png.zip"><b>- Motor traces</b></a></p> <p><img src="images/adrianino/a_20.jpg" width="70%"; max-width="700" /></p> <li><b>Programming</b></li> <p>Here you can find an example of a motor turning left, stopping, and turning right. Here you can find the Arduino file to download.</p> <p><a href="assignments/samdino/motor_samdino/motor_samdino.ino"><b>- Arduino Hello Motor</b></a> <pre><code>//Fab Academy 2020 - Fab Lab León //Motor //SAMDino //SAMD11C const int motor1Pin = 4; // H-bridge pin 0 (in2) const int motor2Pin = 5; // H-bridge pin 1 (in1) void setup() { // set H-bridge pins as outputs: pinMode(motor1Pin, OUTPUT); pinMode(motor2Pin, OUTPUT); } void loop() { // change the direction the motor spins by talking to the control pins // on the H-Bridge digitalWrite(motor1Pin, HIGH); // Turn the motor in one direction digitalWrite(motor2Pin, LOW); delay(2000); // Wait two seconds digitalWrite(motor1Pin, LOW); // Switch off the motor digitalWrite(motor2Pin, LOW); delay(3000); // Wait three seconds digitalWrite(motor1Pin, LOW); digitalWrite(motor2Pin, HIGH); // Turn the motor in the other direction delay(2000); // Wait two seconds digitalWrite(motor1Pin, LOW); // Switch off the motor digitalWrite(motor2Pin, LOW); delay(3000); // Wait three seconds }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/motor1.mp4" type="video/mp4"></video></p> <h2><a id="servo"></a>Servo motor</h2> <p>A very common output is a servo. A servomotor is a device similar to a direct current motor that has the ability to be located in any position within its operating range, and remain stable in that position. In this case I use a 0 to 180 degree servo.</p> <li><b>Connection and schematic</b></li> <p>In this case we only need three cables; one for <b>VCC</b>, another for <b>GND</b> and another for the signal output that in our case we will connect it to pin <b>PA04</b> (4 in Arduino). <b>IMPORTANT:</b> We must supply the servo with 5V. The circuit can be powered by a 9V battery.</p> <span class="image main"><img src="images/samdino/s_21.jpg" alt="" /></span> <li><b>Programming</b></li> <p>Here you will find the programming to use a servo motor. Here you can find the Arduino file to download.</p> <p><a href="assignments/samdino/servo_no_librery/servo_no_librery.ino"><b>- Arduino Servo</b></a> <pre><code>//Fab Academy 2020 - Fab Lab León //Servo without library //SAMDino //SAMD11C int servo = 4; int angle; int pwm; void setup() { pinMode(servo, OUTPUT); } void loop () { for (angle = 0; angle <= 140; angle += 5) { servoPulse(servo, angle); } for (angle = 140; angle >= 0; angle -= 5) { servoPulse(servo, angle); } } void servoPulse (int servo, int angle) { pwm = (angle*11) + 500; // Convert angle to microseconds digitalWrite(servo, HIGH); delayMicroseconds(pwm); digitalWrite(servo, LOW); delay(50); // Refresh cycle of servo }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/samdino/servo1.mp4" type="video/mp4"></video></p> <!-- <h2><a id="lcd"></a>LCD - I2C</h2> <p>For this example I am going to use an LCD with an I2C communication module. In my case, I bought it through Amazon from AZDelivery, here is the <a href="https://www.amazon.es/gp/product/B07CQG6CMT/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1"><b>link.</b></a> This company has a multitude of very interesting tutorials, including that of the <a href="https://www.az-delivery.de/es/products/hd44780-2004-blaues-display-bundle-kostenfreies-e-book?variant=18717479403616"><b>LCD module with I2C.</b></a></p> <li><b>Connection and schematic</b></li> <p>In this case we only need four cables; one for <b>VCC</b>, one for <b>GND</b>, another cable for the SDA and SCL, the I2C connection.</p> <span class="image main"><img src="images/adrianino/a_16.jpg" alt="" /></span> <li><b>Programming</b></li> <p>When we use the I2C communication protocol, the first thing we must do is identify the different slaves that we connect to the bus. The same happens when we connect an input or an output, they have to have a name to identify themselves on the bus; is usually 0x... To do this I use <b>Neil's program</b> to see what number the I2C interface of the LCD uses. On this <a href="https://diyprojects.io/i2c-addresses-of-the-most-common-sensors-and-actuators/#.X4HA82gzZPb"><b>link</b></a> you can find the addresses of the different input and output modules that use the I2C communication protocol.</p> <p><a href="assignments/week11/Hello_I2C/Hello_I2C.ino"> <b>- Arduino Hello I2C</b></a></p> <pre><code>// // hello.I2C.ino // // I2C hello-world scanner // // Neil Gershenfeld 12/8/19 // // This work may be reproduced, modified, distributed, // performed, and displayed for any purpose, but must // acknowledge this project. Copyright is retained and // must be preserved. The work is provided as is; no // warranty is provided, and users accept all liability. // #include Wire.h void setup() { Serial.begin(115200); Wire.begin(); } uint8_t address,count; void loop() { count = 0; Serial.println("start scan ..."); for (address = 1; address < 127; address++) { Wire.beginTransmission (address); if (Wire.endTransmission () == 0) { count += 1; Serial.print(" found "); Serial.print(address,DEC); Serial.print(" (0x"); Serial.print(address,HEX); Serial.println (")"); } } if (count == 0) Serial.println(" no devices found"); delay(1000); } </code></pre> <p>Once the program is loaded through the UPDI, we connect the LCD to the board and the FTDI to the computer. In the terminal we execute the instruction to see the number on the LCD. Listen the serial port <b><i> python -m serial.tools.miniterm /dev/ttyUSB0 115200</i></b></p> <p>In my case the number is <b>0x27.</b></p> <p><img src="images/week11/week11.31.jpg" width="80%"; max-width="700" /></p> <p>Once I know what the LCD number is, I go on to test Neil's program, Hello_LCD.</p> <p><a href="assignments/week11/LCD_Hello/LCD_Hello.ino"> <b>- Arduino LCD Hello World</b></a></p> <pre><code>// // hello.LCD.I2C.ino // // LCD I2C hello-world // // Neil Gershenfeld 12/8/19 // // This work may be reproduced, modified, distributed, // performed, and displayed for any purpose, but must // acknowledge this project. Copyright is retained and // must be preserved. The work is provided as is; no // warranty is provided, and users accept all liability. // #include LiquidCrystal_PCF8574.h #include Wire.h LiquidCrystal_PCF8574 lcd(0x27); // set LCD address 0x27 int count = 0; void setup() { lcd.begin(16,2); // initialize 16x2 LCD //lcd.begin(20,4); // initialize 20x4 LCD lcd.setBacklight(255); // turn on backlight lcd.home(); // go home lcd.clear(); // clear display lcd.print("Hello World!"); // print text lcd.setCursor(0,1); // move cursor lcd.print("Count: "); } void loop() { lcd.print(count); lcd.setCursor(7,1); count += 1; } </code></pre> <p><video controls width="100%"; max-width="800"><source src="images/adrianino/lcd.mp4" type="video/mp4"></video></p> <h2><a id="oled"></a>OLED</h2> <p>For this example I am going to use an OLED with an I2C communication module. In my case, I bought it through Amazon from AZDelivery, here is the <a href="https://www.amazon.com/AZDelivery-Display-Arduino-Pixels-Module/dp/B07F5JKXD9/ref=sr_1_7?dchild=1&keywords=128+x+64+OLED&qid=1601808816&sr=8-7"><b>link.</b></a> This company has a multitude of very interesting tutorials, including that of the <a href="https://www.az-delivery.de/en/products/1-3-zoll-display-kostenfreies-e-book?_pos=3&_sid=180149b80&_ss=r"><b>OLED module with I2C.</b></a></p> <li><b>Connection and schematic</b></li> <p>In this case we only need four cables; one for <b>VCC</b>, one for <b>GND</b>, another cable for the SDA and SCL, the I2C connection.</p> <span class="image main"><img src="images/adrianino/a_21.jpg" alt="" /></span> <li><b>Programming</b></li> <p>When we use the I2C communication protocol, the first thing we must do is identify the different slaves that we connect to the bus. The same happens when we connect an input or an output, they have to have a name to identify themselves on the bus; is usually 0x... To do this I use <b>Neil's program</b> to see what number the I2C interface of the OLED uses. On this <a href="https://diyprojects.io/i2c-addresses-of-the-most-common-sensors-and-actuators/#.X4HA82gzZPb"><b>link</b></a> you can find the addresses of the different input and output modules that use the I2C communication protocol.</p></p> <p><a href="assignments/week11/Hello_I2C/Hello_I2C.ino"> <b>- Arduino Hello I2C</b></a></p> <pre><code>// // hello.I2C.ino // // I2C hello-world scanner // // Neil Gershenfeld 12/8/19 // // This work may be reproduced, modified, distributed, // performed, and displayed for any purpose, but must // acknowledge this project. Copyright is retained and // must be preserved. The work is provided as is; no // warranty is provided, and users accept all liability. // #include Wire.h void setup() { Serial.begin(115200); Wire.begin(); } uint8_t address,count; void loop() { count = 0; Serial.println("start scan ..."); for (address = 1; address < 127; address++) { Wire.beginTransmission (address); if (Wire.endTransmission () == 0) { count += 1; Serial.print(" found "); Serial.print(address,DEC); Serial.print(" (0x"); Serial.print(address,HEX); Serial.println (")"); } } if (count == 0) Serial.println(" no devices found"); delay(1000); } </code></pre> <p>Once the program is loaded through the UPDI, we connect the OLED to the board and the FTDI to the computer. In the terminal we execute the instruction to see the number on the LCD. Listen the serial port <b><i> python -m serial.tools.miniterm /dev/ttyUSB0 115200</i></b></p> <p>In my case the number is <b>0x3C.</b></p> <p>Once I know what the OLED number is, I go on to test Hello_OLED program. You will need to install the <b>Adafruit SSD1306</b> and <b>GFX</b> libraries. If you need more information you can follow the following tutorial.</p> <p><a href="assignments/adrianino/hello_oled/hello_oled.ino"> <b>- Arduino Hello_OLED</b></a></p> <pre><code>/********* Rui Santos Complete project details at https://randomnerdtutorials.com *********/ //Fab Academy 2020 - Fab Lab León //OLED //Adrianino //ATtiny1614 #include Wire.h #include Adafruit_GFX.h #include Adafruit_SSD1306.h #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // // Reset pin # (or -1 if sharing Arduino reset pin) void setup() { Serial.begin(115200); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x64 Serial.println(F("SSD1306 allocation failed")); for(;;); } delay(2000); display.clearDisplay(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 5); // Display static text display.println("Hello, world!"); display.setCursor(0, 20); display.println("Fab Academy 2020"); display.println("Adrianino"); display.display(); } void loop() { }</code></pre> <p><video controls width="100%"; max-width="800"><source src="images/adrianino/oled.mp4" type="video/mp4"></video></p> <h1><a id="conclusions"></a>Conclusions</h1> <p>My idea of creating Adrianino has been so that anyone who does the Fab Academy has no fear of electronics. It has the evolution of the UPDI + VCC, which avoids the need to have an FTDI connected to power the board. It is a <b>modular board</b> that everyone can test the different inputs and outputs that appear in the following photo.</p> <p><img src="images/adrianino/a_26.jpg" width="80%"; max-width="700" /></p> --> <h1><a id="files"></a>Files</h1> <p>Find below the files that I made for this project.</p> <ul><li><a href="assignments/samdino/carcasa_samd.stl"><b>3D case for the programmer</b></a> <li><a href="assignments/samdino/samdino.zip"><b>SAMDino Schematic + Board</b></a> <li><a href="assignments/samdino/samdino_traces.png"><b>SAMDino Traces</b></a> <li><a href="assignments/samdino/samdino_interior.png"><b>SAMDino Interior</b></a></ul> </div> </div> <!-- Footer --> <footer id="footer"> <p align="center"> <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><b>Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</b></a> <div class="inner"> <section> <h2>Follow</h2> <ul class="icons"> <li><a href="https://twitter.com/Adrian_Towy" class="icon brands style2 fa-twitter"><span class="label">Twitter</span></a></li> <li><a href="https://www.facebook.com/adriantrains" class="icon brands style2 fa-facebook-f"><span class="label">Facebook</span></a></li> <li><a href="https://www.instagram.com/adrian_towy/" class="icon brands style2 fa-instagram"><span class="label">Instagram</span></a></li> <li><a href="https://www.linkedin.com/in/adri%C3%A1n-torres-oma%C3%B1a/" class="icon brands style2 fa-linkedin"><span class="label">Linkedin</span></a></li> </ul> </section> <ul class="copyright"> <li>© Untitled. All rights reserved</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li> </ul> </div> </footer> </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>