--- tags: presentations --- # Red Bull Basement # From Ideas To Code Thursday - September 5 10:00-14:00 / 15:00-19:00 [TOC] Nuestra vida se ve afectada en todo momento por un elemento invisible que nos rodea, moldea e influye todas nuestras interacciones con el entorno. La **información**. Intentaremos entender algunas herramientas para integrar este elemento en nuestros proyectos. {%youtube p0ASFxKS9sg %} ## **From Physical Phenomena to Information (10-12)** Oscar Managing/sending/storing information with physical phenomena. * Electricity: V, I, R * Analog vs. Digital * Logic Levels * Binary ### Introduction - getting to know each other Who are we and what are we doing here? ### Electricity Basics In this section, we will understand the basics of electricity and how it can help us represent information. We will start with the simplest of the circuits, and infer from it how the information can be stored, managed and sent over to other components. <div style="text-align:center"> <img src="https://i.imgur.com/jRo3hT6.png" width=600></div> It's all about **electric charge**. As we know, particles can have different charges: positive, negative or none (neutral). We all know that particles relate like this: <div style="text-align:center"> <img src="https://cdn.sparkfun.com/r/400-400/assets/a/6/2/4/4/519fb817ce395fff0a000000.png" width=300></div><br> When, in materials, charge is accumulated differently in some areas, we have what we call **Voltage**. When, through a material, due to voltage difference, these charges flow to meet again with each other, we have what we know as **Current**. This charge flows accross materials: <div style="text-align:center"> <img src="https://cdn.sparkfun.com/assets/9/5/6/1/4/519fcd42ce395f804c000000.gif" width=400></div><br> The nice thing about it, is that we can **control this flow** (or lack of it), and then we can make very cool things! <div style="text-align:center"> <img src="https://cdn.sparkfun.com/assets/a/0/9/4/0/51a52b62ce395f2f25000001.gif" width=400></div><br> :::info **Reference Tutorials** [Electricity basics](https://learn.sparkfun.com/tutorials/what-is-electricity) [Voltage, current and resistance](https://learn.sparkfun.com/tutorials/voltage-current-resistance-and-ohms-law) ::: :::success **First example!** ![](https://i.imgur.com/y1XIX2Y.png) ::: #### Our new best friend The multimeter is a device that help us measure different electricity variables: voltage, resistance, ... ![](https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fcdn.sparkfun.com%2Fassets%2Flearn_tutorials%2F1%2F01_Multimeter_Tutorial-04.jpg&f=1) ### Representing Information Now, let's start representing information with our very basic circuit. <div style="text-align:center"> <img src="https://i.imgur.com/WIbvuIC.png"></div> We will include our first element of control: a switch. :::success **Second example:** ![](https://i.imgur.com/mczRJi2.png) A **couple of questions**: - How much information are we able to represent with this circuit? - How many possibilities do we have? And what if we combine all the circuits we just built? ::: #### Digital Logic in an Analog World **Binary** As we saw before: > "A single switch can be on or off, enabling the storage of 1 bit of information. Switches can be grouped together to store larger numbers. This is the key reason why binary is used in digital systems." > <div style="text-align:center"> <img src="https://usercontent1.hubstatic.com/13809446.gif"></div><br> With a bank of eight switches we can _store_ 2^8^ = 256 possible numbers. Each of those switches is called **1 bit**, and 8 of them are a **byte**: <div style="text-align:center"> <img src="https://usercontent2.hubstatic.com/8735065_f520.jpg"></div><br> This implies then, that to represent information with electricity, we have one very important limitation: information becomes discrete: ![](https://i.imgur.com/9D2GKW6.png) Of course, depending on the amount of bits we use we have a more precise curve: <div style="text-align:center"> <img src="http://pediaa.com/wp-content/uploads/2015/08/Difference-Between-Analog-and-Digital-Signals-A2D_2_bit_vs_3_bit.jpg"></div><br> And if we put enough of them, we can represent more complex things like this: <div style="text-align:center"> <img src="https://i.imgur.com/4MAPJzp.png"></div><br> **Logic Levels** Now that we have talked about representing information with single bit, we have to agree on how things are going to talk to one another. For this, we standardise what we consider as a **1** (high voltage) and **0** or low voltage. We call this **Logic levels**: <div style="text-align:center"> <img src="https://i.imgur.com/zG4NPwb.png"></div><br> **The core component** *Transistor* The transistor is nothing else than an electronic switch. It has three pins: <div style="text-align:center"> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/BJT_symbol_NPN.svg/1200px-BJT_symbol_NPN.svg.png" alt="BJT symbol NPN.svg" width=200></div><br> And it basically works like this: <div style="text-align:center"> <img src="https://www.build-electronic-circuits.com/wp-content/uploads/2014/05/transistor-current-explanation.png" width=400></div><br> We will see how this transitor helps us build more complex things, by controlling how they are connected together. :::info **Reference Tutorials** [Binary](https://learn.sparkfun.com/tutorials/binary) [Why we use binary](https://www.youtube.com/watch?v=thrx3SBEpL8) [Logic Levels](https://learn.sparkfun.com/tutorials/logic-levels/all) [Guerrilla electronics](http://lcamtuf.coredump.cx/electronics/) ::: ## **From Transistors to Microcontrollers (12-14)** **12-14** Victor ### **Making circuits** Circuits can be very simple: ![](https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.makerspaces.com%2Fwp-content%2Fuploads%2F2017%2F05%2Fled-circuit-breadboard-800x474.jpg&f=1) <div style="text-align:center"> <img src="https://www.autodesk.com/products/eagle/blog/wp-content/uploads/2017/02/LED-circuit.png" width=400></div> Or much more complex: ![](https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.khominhvi.com%2Fwp-content%2Fuploads%2F2013%2F05%2FBreadboard_complex.jpg&f=1) ![](http://i.stack.imgur.com/AI4oM.png) Circuits can be [**combinational**](https://en.wikipedia.org/wiki/Combinational_logic), without time dependency (like a mechanism): <div style="text-align:center"> <img src="http://2.bp.blogspot.com/_11-1LH0aw4k/SkyxdsoJKZI/AAAAAAAAAAs/F2UGFxSJAEo/w1200-h630-p-nu/dld+combinational.bmp" width=500></div><br> **Truth tables** ![](https://i.ytimg.com/vi/JQ0JOfxUAgY/maxresdefault.jpg) Truth table for 1-bit Full Adder (above): ![](https://codestall.files.wordpress.com/2017/06/truthtable_1bit_adder_yz.png?w=342&h=229) Here you have them being used in a Marshall Amplifier: ![](https://www.gearslutz.com/board/attachments/so-many-guitars-so-little-time/382906d1391228908-low-wattage-marshall-style-amp-image_1180.jpg) :::success **Example: AND and OR GATES** **AND** ![](https://i.imgur.com/241vHtG.png) **OR** ![](https://i.imgur.com/hemBmIH.png) ::: But they can also be [**sequential**](https://en.wikipedia.org/wiki/Sequential_logic), being _aware_ of their state: ![](https://i.imgur.com/1eOZden.png) In **combinational logic**, the output is a function of the present inputs only. The output is independent of the previous outputs. **Sequential logic** is the form of Boolean logic where the output is a function of both present inputs and past outputs. In most cases, the output signal is fed back into the circuit as a new input. Sequential logic is used to design and build finite state machines. ### **Going integrated** _circuit in a box_ The Apollo Guidance Computer: ![](http://pop.h-cdn.co/assets/17/11/1489433744-screen-shot-2017-03-13-at-33525-pm.png) With some integrated circuits in flat-pack design: <div style="text-align:center"> <a href="https://commons.wikimedia.org/wiki/File:Agc_flatp.jpg#/media/Archivo:Agc_flatp.jpg"><img src="https://upload.wikimedia.org/wikipedia/commons/1/13/Agc_flatp.jpg" alt="Agc flatp.jpg"></a></div><br> Now IC's come in tons of flavours: <div style="text-align:center"> <img src="https://cdn.sparkfun.com/assets/a/9/8/b/8/51c1ea70ce395f5f0d000000.jpg"> </div><br> ![](https://cdn.sparkfun.com/r/600-600/assets/7/a/6/9/c/51c0d009ce395feb33000000.jpg) <div style="text-align:center"> <iframe width="600" height="400" src="https://www.youtube.com/embed/Fxv3JoS1uY8" frameborder="0" allow="autoplay; encrypted-media; picture-in-picture" allowfullscreen></iframe></div> And then they become **programmable** ![](https://i.imgur.com/n7xYW3y.jpg) Early computing machines were programmable in the sense that they could follow the sequence of steps they had been set up to execute, but the "program", or steps that the machine was to execute, were set up usually by changing how the wires were plugged into a patch panel or plugboard. A **stored-program computer** is a computer that stores program instructions in electronic memory. ![](https://i.imgur.com/GcIumJD.jpg) By Parrot of Doom - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=8318196 But then it happened. In 1974: Intel released the first microcontroller, the Intel 4004: <div style="text-align:center"> <a href="https://commons.wikimedia.org/wiki/File:Intel_C4004.jpg#/media/File:Intel_C4004.jpg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Intel_C4004.jpg/1200px-Intel_C4004.jpg" alt="Intel C4004.jpg" width=600></a> </div><br> It was a revolution (specially for printers :joy:): <div style="text-align:center"> <img src="http://2.bp.blogspot.com/-_RtOTJIuT2g/TsUy9TI6itI/AAAAAAAAAS4/lfWcoTSIdEc/s1600/intel+4004+1971.jpg" width=600> </div><br> And from them on: ![](https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Transistor_Count_and_Moore%27s_Law_-_2011.svg/1200px-Transistor_Count_and_Moore%27s_Law_-_2011.svg.png) :::info **References:** [Transistor](https://www.youtube.com/watch?v=sTu3LwpF6XI) [How computer memory works the insides](https://www.youtube.com/watch?v=XETZoRYdtkw&t=6s) [Colossus the first electronic computer](https://www.youtube.com/watch?v=knXWMjIA59c) [How they design the computers they landed astronauts to the moon](https://www.youtube.com/watch?v=xQ1O0XR_cA0) ::: ### IPO <div style="text-align:center"> <img src="https://upload.wikimedia.org/wikipedia/commons/c/c0/IPO.png"> </div> <div style="text-align:center"> <img src="https://i.imgur.com/e5VlrvK.png"> </div> ![](https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fhackster.imgix.net%2Fuploads%2Fattachments%2F215434%2FHH8W64WEHB7R3yEL62Py.jpg%3Fauto%3Dcompress%252Cformat%26w%3D680%26h%3D510%26fit%3Dmax&f=1&nofb=1) ![](https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.electronicproducts.com%2FuploadedImages%2FSensors_and_Transducers%2FSensors%2FDroneSensors_lres.jpg%3Fn%3D1956&f=1&nofb=1) **Interfacing the real world** * [Synthetic Sensors: Towards General-Purpose Sensing](https://www.youtube.com/watch?v=aqbKrrru2co) {%youtube aqbKrrru2co %} **Expression of information** {%youtube SjJkt0zypkw %} ### **Microcontrollers and the Arduino project** A microcontroller (MCU for microcontroller unit) is a small computer on a single integrated circuit. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable input/output peripherals. <div style="text-align:center"> <img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fyt3.ggpht.com%2F-XW1x_JT1g24%2FAAAAAAAAAAI%2FAAAAAAAAAAA%2FlMWjeVh_HEw%2Fs900-c-k-no%2Fphoto.jpg&f=1" width=200> </div> <div style="text-align:center"> <img src="https://i.imgur.com/sEQcWuF.png1"> </div> * The importance of the freedom to use, understand, modify and share your tools. ![](https://hackster.imgix.net/uploads/attachments/907564/dsc01880_aCYwk124ES.JPG?auto=compress&w=900&h=675&fit=min&fm=jpg) * Hardware - Programming IDE and libs - Community ![](https://i.imgur.com/sypsHBo.png) :::info **Resources** [Arduino](https://arduino.cc) [Fritzing](http://fritzing.org/home/) [Arduino reference](https://www.arduino.cc/reference/en/) [An introduction to Arduino](https://www.youtube.com/watch?v=_h1m6R9YW8c) ::: :::info **A success story: the Smartcitizen Kit** [Kit Demo](https://smartcitizen.me/kits/9389) ::: ## **Making things do things (15-17)** **15-17** Oscar y Victor ### Coding languages * Introduction * High/Low level languages ![](https://miro.medium.com/max/1200/1*8j2PmhExz4q87OoddaH7ag.png) :::info **For the geeks!** Instructions for the Apollo Guidance Computer https://en.wikipedia.org/wiki/Apollo_Guidance_Computer#Instruction_set ::: ### Algorithms and flow charts ![](https://d2slcw3kip6qmk.cloudfront.net/marketing/pages/chart/examples/flowchart-templates/simple-flowchart.svg) ### Coding control flow structures ```c= while (condition) { // Do stuff } ``` ```c= if (condition) { // Do stuff } else { // Do other stuff } ``` ```cpp= for (# iterations) { //Do stuff } ``` ### Arduino programming (I/O) * Install [Arduino IDE](https://www.arduino.cc/en/Main/Software) * Comming in or going out? [pinMode()](https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/) * Led on/off with [digitalWrite()](https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/) * Read button state with [digitalRead()](https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/) :::info **Resources** - REPL.it https://repl.it/languages ::: :::success **Example: controlling an LED with code** ![](https://i.imgur.com/1PMwHVi.png) ```cpp= void setup() { // Set pin 2 as output pinMode(2, OUTPUT); } // Loop runs forever void loop() { // Voltage up in pin 2 digitalWrite(2, HIGH); // Wait 200ms with pin 2 HIGH delay(200); // Voltage down in pin 2 digitalWrite(2, LOW); // Wait 200ms with pin 2 LOW delay(200); } ``` **If you are feeling adventurous, try this** ![](https://i.imgur.com/GB3jFmL.png) ```cpp= // Our variable for checking if it's pressed or not bool pressed = false; // the setup function runs once when you press reset or power the board void setup() { pinMode(2, OUTPUT); pinMode(3, INPUT); } // Loop runs forever void loop() { // Read the pin if (digitalRead(3)) { // pressed! pressed = false; } else { // not pressed! pressed = true; } if (pressed) { // Blink it twice digitalWrite(2, HIGH); delay(200); digitalWrite(2, LOW); delay(200); digitalWrite(2, HIGH); delay(200); digitalWrite(2, LOW); delay(200); } else { // Turn it off digitalWrite(2, LOW); } } ``` ::: ## **Making things learn (17-19)** **17-19** Oscar y Guillem * Networking * Concepts of Databases, Big Data, Machine Learning :::warning [The Internet presentation](https://www.dropbox.com/sh/weidfdjwh6nhsd2/AACKiu316itGi8a6LNsYWlbea/The%20way%20things%20work%20-%20MDEF/keynotes/PDF?dl=0&preview=MDEF+TWTW+Internet.pdf&subfolder_nav_tracking=1) ::: **Some wrap-up** [![](https://i.imgur.com/Y5Di3h8.png)](https://visual.ly/community/interactive-graphic/technology/network-graph-programming-languages-influence?view=true) **Node-red** Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click. ![](https://nodered.org/images/nr-image-1.png) :::info https://nodered.org/ ::: :::success **Telegram BOT** Send 1 or 0s here! t.me/fablab_rbb_bot ::: **Machine learning** > Machine learning is a data analytics technique that teaches computers to do what comes naturally to humans and animals: learn from experience. Machine learning algorithms use computational methods to “learn” information directly from data without relying on a predetermined equation as a model. The algorithms adaptively improve their performance as the number of samples available for learning increases. Deep learning is a specialized form of machine learning. ![](https://insidebigdata.com/wp-content/uploads/2017/02/Deep_Learning_Icons_R5_PNG.jpg-1024x651.png) **Inspiration** ![](https://www.raspberrypi.org/app/uploads/2018/08/WatchfulPositiveBullfrog-size_restricted.gif) From: https://www.raspberrypi.org/blog/android-things-expression-flower/ <iframe width="560" height="315" src="https://www.youtube.com/embed/43cJ0XZKiaY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br> From: https://www.raspberrypi.org/blog/augmented-reality-projector/ :::warning Do not try to make your own program from scratch in a month! There is a lot done in the field! Check some repositories: https://github.com/opencv/dldt https://github.com/opencv/open_model_zoo/ ::: :::info **Resources** [Machine learning mastery](https://machinelearningmastery.com/) [Raspberry pi projects](https://www.raspberrypi.org/blog/tag/machine-learning/) [Recognising gestures from wifi changes](https://www.youtube.com/watch?v=tJCQZxi_0AI) **Computer Vision:** [OpenCV](https://opencv.org/) [YOLO](https://pjreddie.com/darknet/yolo/) [YOLO DEMO](https://www.youtube.com/watch?time_continue=13&v=MPU2HistivI) [YOLO TUTORIAL](https://machinelearningmastery.com/how-to-perform-object-detection-with-yolov3-in-keras/?__s=bi1uspbqquxemho37zzf) [Object detection](https://machinelearningmastery.com/how-to-train-an-object-detection-model-with-keras/?__s=bi1uspbqquxemho37zzf) [Face Recognition](https://machinelearningmastery.com/introduction-to-deep-learning-for-face-recognition/?__s=bi1uspbqquxemho37zzf) [OpenCV and raspberryPi Ping Pong](https://www.youtube.com/watch?v=YbO6lZHlJvw) [Laser tracking with opencv and raspberry](https://www.youtube.com/watch?v=oJAl9Yd3kNo) **Voice recognition** [jasper](https://jasperproject.github.io/documentation/) [Sopare](https://github.com/bishoph/sopare) [Snow Boy](https://github.com/Kitt-AI/snowboy) ::: ## General resources ### Sites * [hackaday.com](https://hackaday.com/) is one of the best blogs on DIY inventions and hardware hacking * [lowtechmagazine.com](https://www.lowtechmagazine.com/) many technology choices are political and economic, looking at past forgotten technologies helps us see the future * [archive.fabacademy.org](http://archive.fabacademy.org/) 10 years of project from Fab Labs around the world. Sometimes hard to browse but inspiring! * [learn.adafruit.com](https://learn.adafruit.com/) a really good site for electronics and programming tutorials, especially for beginners * [instructables](https://learn.adafruit.com/) more and more DIY tutorials, sometimes aren't good but there's a lot