Crazy about Arduino - Level 1 - Start your Journey with the Amazing Arduino Development Platform | Idan Gabrieli | Skillshare

Crazy about Arduino - Level 1 - Start your Journey with the Amazing Arduino Development Platform

Idan Gabrieli, Pre-sales Manager | Cloud and AI Expert

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
68 Lessons (3h 13m)
    • 1. Course Promo

      3:35
    • 2. Course Introduction

      0:50
    • 3. What is Arduino

      4:48
    • 4. Endless Applications

      2:26
    • 5. Are You Ready Software Checklist

      3:03
    • 6. Are You Ready Hardware Checklist

      6:06
    • 7. Exploring the Arduino Platform

      0:58
    • 8. The Arduino Uno Board

      7:19
    • 9. Other Arduino Boards

      2:36
    • 10. Expansion Shields and Modules

      6:09
    • 11. Arduino IDE

      5:41
    • 12. High Level Board Overview

      5:45
    • 13. Running Our First Program

      3:53
    • 14. Introduction to Arduino Programming

      0:58
    • 15. Sketching in Code

      2:34
    • 16. Basic Sketch Structure

      1:04
    • 17. Variables Declaration Introduction

      2:03
    • 18. Variables Declaration Data Types

      5:00
    • 19. Variables Declaration Naming

      1:26
    • 20. Variables Declaration Scope

      2:19
    • 21. Setup and Loop Functions

      1:30
    • 22. Custom Functions

      2:27
    • 23. Operators

      0:46
    • 24. Control Statements Intro

      1:06
    • 25. Control Statements: if else

      2:29
    • 26. Control Statements: switch

      1:39
    • 27. Control Statements: for loop

      2:47
    • 28. Control Statements: while/do loop

      2:11
    • 29. Using Libraries

      3:19
    • 30. Comments in Code

      1:56
    • 31. Learning by Doing

      0:58
    • 32. Our Arduino Project

      1:48
    • 33. Breadboard

      6:22
    • 34. Step 1 - LEDs Test and Animation Wave

      1:06
    • 35. Step 1 - Project Building Blocks

      0:40
    • 36. Wiring LEDs

      2:25
    • 37. Reading Digital Inputs

      1:24
    • 38. Pullup Down Resistors

      3:59
    • 39. Final Circuit Review

      2:42
    • 40. Project Review: Step-1A

      3:29
    • 41. Sketching in Code: Step-1A

      8:47
    • 42. Handling Switch Bouncing

      4:11
    • 43. Sketching in Code: Step-1B

      4:54
    • 44. Project Review: Step-1B

      1:31
    • 45. Step 2 - Control LEDs Speed and Brightness

      1:05
    • 46. Step 2 - Project Building Blocks

      0:40
    • 47. The Variable Resistor

      2:28
    • 48. Circuit Design

      0:46
    • 49. Step 2 Circuit Design

      1:17
    • 50. Reading Analog Inputs

      2:43
    • 51. Utilizing the Serial Monitor

      3:48
    • 52. Setting the LEDs Speed

      6:32
    • 53. Sketching in Code: Step-2A

      3:41
    • 54. Project Review: Step-2A

      4:03
    • 55. Writing Analog Output

      1:36
    • 56. A little bit magic with PWM

      4:10
    • 57. Setting the LEDs Brightness

      1:05
    • 58. Sketching in Code: Step-2B

      2:41
    • 59. Project Review: Step-2B

      2:34
    • 60. Step 3 - Motion Detector

      1:00
    • 61. Step 3 - Project Building Blocks

      0:39
    • 62. The PIR Motion Detector

      4:43
    • 63. Step 3 - Circuit Design

      0:46
    • 64. Sketching in Code: Step-3

      4:25
    • 65. Project Review: Step-3

      3:33
    • 66. Course Summary

      0:34
    • 67. What did we covered so far?

      4:16
    • 68. What Next ? Level 2!

      0:49
13 students are watching this class

About This Class

d46d6967

The Crazy about Arduino Training Program - LEVEL 1

  • Do you like building “things” by yourself?
  • Are you looking for ways to easily combine software code and some hardware components?
  • Did you ever wonder how electronic devices are really working?
  • Do you have some creative ideas and you just looking for ways to easily prototype them?

If the answer is “YES” for some of the questions above then you just landed in the right place!. Arduino is an amazing development and prototyping platform with endless possibilities for Do-It-Yourself Makers looking for ways to express their creative mind and technical capabilities. 

Are you Ready to start being “Crazy” about Arduino....?  ;-)

Transcripts

1. Course Promo: way, go, touch, use or play will find Elektronik devices. They're embedded everywhere. Those products are based on a combination of hardware and software. Now, would you like to learn how to create in programmes such devices? Do it yourself. If the answer is yes, you just arrived to the right place. Albarino is an amazing, easy to use platform for landing electron ICS software programming, building all kind off things by ourselves. And it is really not a rocket science. The ability to think on some innovative ideas, smartly combined electron ICS and Web technologies and quickly prototype it is. What do we know is all about? We will start with a nice introduction about Audrey. Know what kind of application we can build? What kind off options are available to expand the board capability. How to develop an upload software using the Dewey No, I d. Then we will zoom into the details programming syntax like building function, using operators and condition statement how to read and write digital or analog signal will do all of that while building a complete are doing a project with digital and analog. Senso designed the needed circuit prototype the project using bread boat utilized led push button, resist or viable Resistol Motion Sensor and more crazy about Arduino training program is divided levels in each level. We will learn different aspect related to the do we know and the evolving eco system around it, building our knowledge in step by step. This is Level number one Toby used as an introduction course for new student that are entering the world off are doing no makers. We are going to combine a little bit, Terry and more emphasize on the practical side, with a step by step short learning cycle. We will use different free software tools to help us design circuit and uploads offer toe the Reno It's section include a quiz to test your knowledge and understanding and off course. The platform enable you to share your thoughts and questions. My name is he done it walking in the software industry with a strong linkage to the business side. I ever comprehensive knowledge in electron ICS networking, ICT infrastructure that that a base and worked technologies and, of course, Elektronik programming. Like every journey, we need to start with something so it's up to you. Are you ready to start being crazy about 2. Course Introduction: hi and welcome to the Crazy about Arduino training program. This course is really the starting point for using Arduino, and that's why it is called Level one. My name is he done, and I will be your teacher now before we start a. I strongly suggest toe blend. This course in this suggests order, meaning section by section using play the software application that I'm going to suggest to download and feel free to drop questions and, of course, review questions and answers. Okay, let's stop. 3. What is Arduino: The first thing we need to learn is what is are doing and what we can do with it. Well, how do we know? Is Elektronik prototyping platform looking like a piece off Elektronik boat as you see in the picture on the right. Now, using this platform, we can prototype all kind off electronic device controlled by software that we can easily right. The second important thing is that the AL do you know, can be used as a central brain. So we can, while all kind off things together. And by doing that, we can turn that, do you know, in tow, endless Elektronik application? And this is what we are going to see If we will visual A that in a very simple diagram, then the Arduino is used to create a digital interactive device that can interact with the physical world around us, meaning a sense and controlled the outside environment. By using an almost unlimited range off input and output device, we can program the needed interaction with the physical world required to create some specific functional device that is performing a specific task. In addition, we can make our albarino device a connected system that is connected to the Internet. Using all kind off means it can be Uihlein like Internet wireless, like y five or Blue Foods or whatever. Now, if you think about it for a second, this is what the Internet off things is all about. Building smile devices that are acting as connected entities and are sharing a real time information with Internet Cloud. And this is a very powerful A way to extend the usage off the artery. No system for my developer. Their point of view, Dad, I know is a combination off hardware boards with some desktop application called Al Doing No I d it that help us Tobe or Graham the boat. Now they're all kind off are doing product or boards that are coming with different capability and, of course, different price. But the building blocks are almost the same, Looking on some specific example off in a green aboard at the end. This is the some printed circuit board that is specifically designed to use a microcontroller chip as well as all kind off other connector and component that at the end , allow us toe touch input and output data. We learn more about it in the next section. And other interesting things we can say about odd, we know is that it's an open source hardware blood from Maybe you're familiar with out in the in this in the regular soft on pieces that there are some software that the open source and in the case of Fargo, know the meaning is that anyone can download the design files original design first and create the same product or maybe a new one. And this is why we will say that some companies are selling the Albarino official product and other companies are selling what is gold compatible of we know product that are looking and functioning the same as the official. Same is the official, but they cannot use the protected name. And we know so you will see the same look and feel but different, different name now for programming that we know brain that is called the microcontroller, and they're doing a platform. It provide us a very nice integrated development environment. This is what is called I D for free, and we can download that for made Internet, and the court itself is based on the C in C plus plus programming language. Now why this Arduino platform is soap operas, probably because it is really affordable, low cost product that people around the world can easily buy and start, play and try building all kind off application around it. 4. Endless Applications: now to the question. What kind off application we can build with Arduino now There are really endless options of an application, and we can build with the platform. What we can do is really limited only by our imagination and creativity. If I will compare it to some musical instrument, and then the question can be what music we can create with such musical instrument. And of course, the answer is that we can create endless variation off music. The same goes without. We know we can do without whatever we wanted. Toby. It can be used to build a control system and smiled. War Boat that Arlo Gail for collecting information game controller, Web servers and more and more I O. T. Is L. A t one off the most exciting area off really endless innovative application. And, yes, that we can be used to prototypes. Such innovative ideas, if you will surged, ain't in it about out doing a project. Then we were available toe find huge amount of project ideas being created by all kind of creative people worldwide. When we have the options to easily connect hardware and software, then it is becoming really interesting and fun. What can we do with such combination? Why it is simple to do all of those things simply because the Arduino is, at the end a small computer with options to connect to a wide spectrum off external a component. It's such a sense, so that are being used everywhere today. Simple led device or maybe connecting toe LCD display Moto's two great physical motion a wild line and wireless for that communication. Storing in logging information locally on some SD card interact with mobile application and more and more. 5. Are You Ready Software Checklist: Okay. I'm sure that you would like to start learning how to use the hard We know blood room it now before starting. We need some specific software tools in some small amount off. How well a component. I'm assuming that you would like to build things by yourself, and I just watch a lecture now. If that the case, then let's see what is needed. The first software is, of course, they're doing No, i. D. This is our desktop software to create code and upload that toe the house with a platform. You can download that from the official Arduino site. It is completely free. Second program is called Freezing. It is usedto easily design name, schematic circuit, and I'm going to share with you the files I created for the project we're going to build so you can review that US question changing into one. It's also a free program. Let's see the two application for a minute. I'm right now in there. Official site off felt. We know and you can see the Ural over real. That all kind of things that we can do with that site, for example, lettering all kind of things that related to their do. We know I am looking on product that you can buy, and what I would like to show you right now is where to download they're doing. Why atheists. I'm going to in tow over Real. And that's the most recent version off the Arduino software I D. And of course, it's supporting multi hoists a platform. So it's supposed Windows making Toshio Os and Linux. So download the irrelevant it just or application and start using that the next software would like you to download. And it's called fitting. You can see also the UML over Real. As I said, it's also an open source platform. Eso if you would like, you can download that for feel donate something today to the site. So I'm going into the download section. Designing what I would like to. Dio would like to donate something and just download the version. You could see the relevant release right now. A. In addition, not just for Free ting, also for the away. No, there is a very useful inactive forms in those sites. Okay, so you can as question they've used all kind of France's form a other people so This is true for free thing and also truthful that we know a site. Okay. Very useful way to learn from other people. 6. Are You Ready Hardware Checklist: The second requirement is related to hardware and this is a little bit investment from your side. If you would like to build things by yourself, we have two main options. Option number one is to search for Albarino starter kit in eBay, Amazonian, other sides, As you see here now, such package are usually very cost effective s so I think that's the best way to go now. Option number two is to buy individual component one by one. If you would like different quantities and quality and so one something that you cannot change the name starter kit package that you're getting everything with some fix the quantity and for example, the package that weaken by any bay is usually not. The official are doing a vote. It is some more cheap compatible boat. Still, for example, I'm using that and everything is working is expected. So please download the excel file I'm going to provide if forgetting a list off needed component, you will see that in the project that we're building in, it is actually very simple component. Now off course, the doing of star ticket Is that you that you can find it and it includes much more component that we are going to use, not in discourse. We're going to use them. A. Hopefully in next level's going forward. We will do a quick search on eBay to review such package and expected content now regarding the hardware component. But let me just show you some example off searching for such kit. So I'm searching for our do we know. Oh, do you know Starter Kids? Click on the search and I'm getting result okay, and the headless option is place to buy such kit I for myself. Both sides shame, kid form a Chinese supply, and I'm pretty happy without it's very cost effective. Let's see such one example. And of course, when you are buying something for me, but just make sure that the supplier is a good rate, eso will be most safe and reducing the chance of getting something that is not walking. Let's see the content content off such a starter kit is an example. So you see endless, really endless component that are coming with that a platform here in the middle. You can see them they are doing aboard itself. We using a different name convention not out. We know, because this is like a compatible board. And many, many small items that needed for building a circuit like capacitors die owed em a switchback baton. I am displays leads and the wall in many all kind off sensors and cables and the one that we are going to use in different level in our training program. Okay, so that's definitely very cost effective to buy some kit that will help you to start your journey with without we know, the same goes to Amazon. If you will surge that we know started. Kitty will get a long list off a result. And for example, the 1st 1 is the official that we know Kit and a little bit much more. I mean, much more expensive than buying that in eBay. And then you're getting off course the regional are doing aboard. Okay, you can see the things that you're that you're getting with a platform. If I will compay Teoh, toe other kids, this is like him. Maybe I'm getting the original. We know border them, but I'm getting much less safe type of faith component and that I needed toe build and see stems. If I will go back. You can find other type off a off AM kit coming from different supply, a different price, different am component that are coming with the kid. If we click on someone, then you can see that. Okay, for example, this is not an original out doing a boat. This is a compatible boat. But as I said, I'm completely okay without it, it's finally, which meets walking for May. Just make sure that you are purchasing the Arduino Uno release three because there are also other type off doing a bold for we'll go down, for example. You have another type of board that's that's the one and also that's that's okay. I will recommend if you're a star. If you're only starting without doing, you know, and do we know no? A version released raises is more than fine toe build many, many things, many, many interesting things. Also, there are dedicate supplier just for the whole ecosystem related to what we know, for example, that spark fun so we go can go into those sites and evaluate some specific component the kids that you would like to purchase and compare. Compare price and see whatever I am, whatever its its best forward for you 7. Exploring the Arduino Platform: writing and are going to suffer, require a little bit background in programming. If you already have it, then it's going to be like a piece of cake care for you. And if you don't have it, don't worry. It is really not rocket science, as we are not going to write one million lines off court to launch a rocket and bring it back, Most of the program that we will write are usually small and not so how to develop, understand and reuse for other project. Now, writing few lines of code and seeing something walking in the physical world is really the fun part. So in this section we will review the basic building blocks and syntax being used in a, you know, a programming language. 8. The Arduino Uno Board: what we're looking right now is Dad, we know, you know, Revision Tree boat. And at the lower middle is the brain off the board what is called the microcontroller. It is a tiny computer that contains the process, so toe execute instruction and that is similar to the CPU that you're using in your desktop or mobile application. Now it's includes small amount off memory. On the left side is the Universal Serial Bus USB connector. This help us to connect the boat toe? Ah, well own desktop computer providing remain useful properties. The 1st 1 is to supply power to the board. The second is to upload our program. So that, we know is is at the end. We need to tell that way no board what to do. And the last and the last thing is to send and receive data form our computer, something that is very useful when debugging and looking for errors on some software. Now next to the U. S. B. There is another circuit that is called external power. The socket allow us toe power that we know from an external power source. Instead of fusing the USB cable as a power source. The supply could be from a C to D. C adaptor. Like many appliance that we use in our homes or from some battery. Also next to the USB socket, we have the reset button that is used to reset the program on the ongoing No or Stop it completely. When we held a that down for a long time, the boat as full light emitting dialled in short leads labeled L. Alex takes an own in Generally lead is a component that produce light when an electric current flow to it will use it a lot. In our project, it used everywhere we go right now in almost endless application. So on the right side and the lead labeled own indicates in green collar. When the board as power, the lead's label Ticks and Alex light up when data is being transmitted or received between the Arduino and some a touch device via the serial port. For example, if I will try to upload a program into the albarino board, then in a very short time you will see the ticks and Alex lighting on and off. The last one is called the L lead is actually for us, meaning we can tend that led old enough using the software command, and it is also connected to the digital i o. P in number 10 that we'll see very soon. So this is a great output. Options on top off the boat for testing our program and to save things are walking just below the micro controller. There are two goes off more socket. The first offer US power connection, meaning external competent that we're going to connect to their doing aboard can get power from that pains something will use all the time so we can use the power pains to distribute power to input and output whatever is nearing our circuit. In addition, if you look on this role on the right side, there is a being that is called V in which stand for voltage in meaning it can be used to supply the window board a external power instead of using them the power socket. Jeanne D. Mark the grandparents at which essential to complete the circuit. Now there is also a Ted ground. Just next toe depend a 13. All of those campaigns are linked and sharing the same account Now, in addition, we can use the five voto three point revolt to supply and the needed voltage level, toe power, other component. A whole circuit. Also in the same war, we have the ability to use an external recent button instead off utilizing. They read the recent. But in what we see on the left side that is coming already is part of the board. The second hole offer six analog input a zero to a five that I used to measure electrical signals that very Ryan voltage. Like a component like analytical sensors, an analog value is taking from a range of value. In our case, the ranges between 0 to 5. Along the top of the board, there are two more rose off socket A opens, whatever you call it, a number A number 0 to 13. This is the digital input and output that I used to send and receive digital signal. The many off Dig It Al is that they're they have only two states on and off. In our case, it would it, meaning that the value can be 05 old but no value in between, so they can either detect whether or not an electrical signal is present on that. Pain or generates is output a signal using a commands in our in our sofa. In addition, digital pains you on one also known as serial port, which is used to send and receive data toe other device. Okay, don't worry. If you don't understand everything right now, it is just in high level. Overview him now. What about analog output? Okay, so you don't see any pains that are being used for final output, but we have some solution for that. And this is where you see some specific pains with with the Mark ofa Tilda next to it. There is some solution for imitating analog output, something that is gold. A p a W M pulls wide. More delay in modulation, which is a technique that we can use toe create something like similar toe on a locate output in these being used in all kind off, off application, we are going to present it. It's part or far. We're project the pins that are marked with distilled all pains, say 356 and 9 10 and 11. So only for them we can use this puts wide modulation a picnic 9. Other Arduino Boards: As I said before, there are many types off Arduino boards available, each with its own, a design size and specific feature that can support different type of application. Now, for example, that we know mega bored, they provide more input and output beans compared today, you know, board on the other end out. Do we know and I know is very small in size. Another nice example is the lily pod. Aren't we know that is used for all kinds off wearable a project A and more with low power consumption. Now, of course, there are more a boat. Let's see the official boat. In the end, we know a site I just entered into the Reno and official site as well. So before now, under product category, you will get some nice summary, all off all available e official doing a product, and you can browse between them and see an additional info on each one off them. For example, if I would click on Alguien Omega, then I can see am the board itself. Some explanation about the feature on that board and some project that other people created using this board, the technical spec, some the communication and an additional info that can take in years toe. Understand if this is their board that I would like to use if I would go back present. The any part that we know is be, as they explained, is more a use for wearable a project. Um, you can see that off. Really. It's pretty small form factor and board. It would call kind of features capability. Do you see that Operation Voltage? It's not five vaulted slow where you condone onto the communication and see some additional information. A related to that. A board And I said, This is the official boards for each boat aboard. We can search that and some find also compatible board that are doing the same. But this is a good place to say at the possibility of the options under there. Do we know a product 10. Expansion Shields and Modules: each are doing a bow that we will use as a DNC fix set off functionality. And, of course, we cannot change it. Now, based on some project requirement, it may be more options than we have in our board will be needed so we can decide to maybe purchased different or do you know Bode with more options? However, it is more common to use a type off expansion. One is called Shields and the other one is called Models or break Board. Let's start from the 1st 1 So, although you know, shield our boat, that can be flagged on top off the Arduino board, extending its capability now they are, of course, limited toe specific boards because the pains needs toe match to each other will sit in the next picture. Still, the positive side is that we don't need external while to connect between them between the the shield expansion, a board and their original Arduino board. In addition, for each of you know shield, we will have a set off pre defined function under what is called library that will help us to easily use it. Let's see some very common example this specific a Arduino shield Allow us to connect our doing. Oh, you know, or are doing omega to the Network A or the Internet and also retrieve or store files on a micro SD card. It's simply plugged on top the others that I let the exist on the Arduino board, and we can stuck even additional shield on top of it. So Eddie had no soldering wiring is required to connect between them, and that's all we need to connect a network cable to the expansion issued. We have RJ 45 connector for that, and that's all. And it will get the shield will get the power directly from their doing. No, a power supply. We are going to use this aEterna chilled in one off our next course levels is this is a little bit more advanced feature in other widely used options. To extend the capability off, our Arduino boat is to use models or also called breakout boat. As you know, many electronics companies are producing small, integrated sick A that they're looking like computer chips that can perform specific tusk now. Usually it is not so easily to connect to interface with such integrated the circuit because the size is small and they require also additional component to appoint. So the idea of a breakout boat is that it break out such small paints off the integrated circuit into a printed secret board. That is its own pains that are spaced perfectly for connecting external wiles and giving us a much easy access to use the integrated ticket and off course, putting all any needed external component beside they integrated. Get around it. So everything is backed in a small factor on some printed boat, and we just need to interface with out with an external connector. Now, believe it or not, we use it a lot. This is, for example, a microphone toe help us to sense sound and too connected. It's a sense of to our do we know device. They're all kind off Arduino shield we just saw there than it shared the real. Also, WiFi. This is Dr Mortals into one, and also there are so many types off models or break out my balls that we can use. They are great Elektronik building blocks, and you should learn to use them. Take, for example, your 100 phone. Do you really think that one manufacturer is creating the whole component in that phone device. Know they're using it to get a ticket, that coming from a company, that they're coming for many manufacturers and use that is a building block. Now, in our example, we can see here blue food models, GPS, ultrasonic distance, Senso microphone. It could be temperature sensor pressure sensor led and the LCD display and more and more and more. Now, since the pain out off a breakout board is not specifically designed to some specific udwin , whether it means that we can use a breakout bored with any other microcontroller development, a board, whatever we want, which gives them a bit more usable options than the Arduino Shield. Also, you can get that in most cases we will be able to find a break up break out board that does the same thing is a dedication. So at the end, it's up to us to decide which we would like to go. Maybe also, this is a price issue. Maybe they're the model itself will be cheaper than the shit. So this is also something to consider 11. Arduino IDE: we saw that the developing platform for Do We Know is called Arduino I D. And it is including called Ed It'll and Simple Mechanism to Verify and Load the program. The software Week eight is called Sketch, and the language Syntax is similar Way Toe C and C C plus plus. In addition, it's coming with the common input and output procedure that we can use a collection of function for some feature that are grouped under specific library, for example. And we have library for Internet communication and all the function of grouped under the library so we can easily use that full I p communication and last thing. We can run it on Windows there May Quests and Lennox Operation System. Let's quickly review a doll doing no I d software because we'll use it a lot. This is simple desktop application that you need to download any style from the Algerian official site. As we saw in the getting a started section. The software user interface is divided to tree main area. In the middle is the court Edie Toll for developing our sketch, and below that is some feedback. Also, while verifying sketch in applauding that to the board, just above the coded itto we have several a button. 1st 1 is to verify the code in our sketch. Let's click on that right now. You can see something is working right now on the right side will get the message. If the sketch was verified correctly and you see that everything is being done and everything is OK, next button is toe upload the full exam toe. The AL do we know, assuming a well doing a boat is connected using a USB to the computer with the softer. So in my case, it's connected. So I will upload a simple sketch to the board I'm using right now clicking on that. It's running and you see that it's being done uploading right now. This sketch is uploaded to my boat. Additional buttons are for opening a new sketch, opening an existing S schedule to save our sketch. We are walking right now at the end. On the right side, we can open the serial monitor screen. It's something we will use later in our project to present information it coming from the Arduino going up to the menu ball. We have the standard a file menu to open and save sketch. And in addition, I can open many nice example being constantly updated by the are doing a project helping to share knowledge in court in the going of window community. Now the example are divided to subject. And let's open one example. I'm clicking on that and I'm getting that is a new sketch, and I can start using that. Maybe copy the relevant code or just the code in this specific sketch. Next menu is the edit. With standard editing options inside the sketch menu, we can verify and upload the sketch quickly. Open the folder location, clicking over it in open the folder location off our sketch file to easily find it in our computer and also include specific libraries, something that will use later if I will press on one library. Justin is is an example. A new line will be added to our good with the world include and the name off the library. You can also write it down manually. The list off libraries are coming without we know a I D installation and also updated from time to time. Still, you have also the options toe add an additional external libraries if you would like, and that is not included. Next menu is tools where I should verify A that are doing I do is configured on the right and we know type just over you and also the relevant logical a communication port. You can say that is configured toe. Come for this. Usually done automatically wherever. If something is not working, you could check those setting. Okay, so this was a quick overview off the old way. No, I d. And now let's do the same for that were, you know, boat. 12. High Level Board Overview: now, I would like to quickly review that. You know, you know, a boat before running our first problem. OK, so let's styled with albarino brain. The microcontroller is this long black chip that is doing all the hard work, meaning running every line in our program. And we're doing so WeII. Send and receive analog and digital signal formal kind off external component store information in memory, a perform calculation and more almost like your desktop computer CPU. Next is the power. Soak it it for feeding the boat with voltage from external power source like a C to D C adapter A or some buttery when the board is getting power. And then this only, well, a light in green provider saying indication that we have power to the board just above the power. Soak it. We have the USB socket that is usedto power at the board, upload the programs and monitor the sale. A port, the reset button is used to reset their doing a program it to start all over again from the first line off a code. In some cases, we would like our project toe have additional reset button Toby located in another location . So for that we can use the base, its socket it, that we have just overview for achieving the same goal. One thing I almost forgot to mention is related to the name off the boat. If we look carefully will see that it is not called albarino. And if you remember, we learned that many are doing aboard are actually compatible board and not official boat, because the name I'll do, you know, is protected brand name. And this is why we will see some other names being chosen and by the specific producer off that boat. Still, it is functioning like the official board moving in. Next. Let's review the tour off. Soak it. The upper one just over real is the digital input and output. They soak it that also called pence, starting from zero a tow 10 meaning we can connect an external digital device, say like a digital sensor. In addition, some digital pains are marked with a small a Kelda Okay, like the following pains, providing us indication that this specific pains also support purse. Why the modulation? Later in this course, we will learn how to use a the P W. M in the same room just after prenatal. Then we have the ground s soak it, this one it that may be used to provide ground reference to extend a LASIK it looking on the world below. On the right side, we have six analog input a pins and please note it is used just for input, a not output starting from a 08285 Moving on on the same old toe. The left side and we have all kind off power connectors at the 1st 1 is V in voltage, a input that could be used to feed our boat day with power from an external source without using a dedicated power. Soak it, meaning this dedicated power socket or the USB connector. Next, we have toe ground, a connector, a five, both in a three point revolt. Output that are usedto Powell all kind off external component. There's some additional pains called I see a speak. This one and this one and that's a little more advanced option will cover in the next level , Not in this course in the middle of the borders. Some very useful leads. A the ticks and Alex. They are used to indicate that the boat is sending or receiving information. So in the case, we upload the new program toe the boat. Those leads will blink on enough for a very short time. The last lead him over called l lead, and we contend it on and off, using our program for and usefully usage. Okay, I think that summarised the main aim functionality that we having done. We know, you know, board and let's move into the next chapter of allocating some simple software and running that on our board. 13. Running Our First Program: in the previous two chapter we saw there doing no idea. Soft little. And do we know you know, board? Now it is time toe combined between them. Meaning, write some simple, sketch a polity to the boat and see some result. My Arduino is connected right now using a USB cable toe my computer, and I'm using that doing. No, I d. Let's write some lines off code, and please don't war if you don't understand them. And 1% is we're going toe cover that much more deeply in the next section. What I would like us to do is to write a program that will turn the lead l on for one second and then a off for three second. Very simple. Now, if you will a d f the hardware equipment, then place. Try that by yourself, as in later stage, we will build much more complicated system. The good news is that we can find in the example such almost similar sketch Just goto file on the example in the basic category. Choose blink and let me bringing that to the screen. And now we are getting some sketch being developed by the while doing no community. First few lines are comments that remarks used to describe the goal off that sketch in high level. Going below, we have the set up function where we set being 13 is output for kissing a. The relevant lead. Now the main a program body is inside the look function. Firstly, a line right, a five volt to the pain 13 and then wait for one second, then send again to the same being zero volt and then wait for a another one second. Now we would like to change that to three seconds. This what we would like to achieve now before uploading the software we click on Verify toe , verify that everything is OK. Okay. Clicking on that waiting for the it fit big below Now I didn't get any old message. It's being done and I can now doing the upload. Now we can click on upload now doing the uploading time off. The court will see that the Peaks and Alex leads are blinking for short a period. Let's do that. Clicking on upload. You see very fast that the ticks and Alex were blinking as soon as this finished that we know microcontroller will start turning. I will program forever. Now, looking on the boat, we can see that they the lead blinking on enough based on the delay time in our program. We just passed the first milestone, and now we know how to upload the poor Graham two that we know that is actually doing something. Still, we need better understanding about the programming syntax, so we'll be able to develop much more complicated sketch, and this is something we will cover in the next session. 14. Introduction to Arduino Programming: writing and are going to suffer, require a little bit background in programming. If you already have it, then it's going to be like a piece of cake care for you. And if you don't have it, don't worry. It is really not rocket science, as we are not going to write one million lines off court to launch a rocket and bring it back, Most of the program that we will write are usually small and not so how to develop, understand and reuse for other project. Now, writing few lines of code and seeing something walking in the physical world is really the fun part. So in this section we will review the basic building blocks and syntax being used in a, you know, a programming language. 15. Sketching in Code: we enter the land that they are doing a program is called Sketch, But why it is called that way. Well, programming is usually thinking and creative process where we try to solve specific problem now, when we have some solution to the problem or group of problems. Oh, you have a new i D in our head. It is important to write it down or sketch it as soon as possible, as it is important to catch that moment off. Inspiration, I can tell you that in my own walk, all kind off ideas are jumping toe my mind, and I always write them as soon as possible. It can be on a piece of paper in my mobile device or in my desktop computer. Now back to the Arduino when sketching in code. It is okay to let your creative mind take control and put less emphasize on creating the perfect could. It is okay to make me steak and lemming. What is walking or not walking. There it is to keep improving your code, keep trying new things and learned from others. Another important aspect about learning to code is to build a step by step framework around your project. Specifically, when we combine software and hardware, the meeting off such framework is toe break any project to little pieces, same as we break a big problem or a challenge to little problems en dealing each one at a time. For example, let's say that our project is going to combine Tree. Different, Sensible. It makes much more sense. Toe build and test. I will good for each sense. So at the time, don't try to build and sketch everything into him. Try to walk in incremental steps, baby steps. If something is not walking as we expected, we can just undo fix the last incremental steps, and at the end it will be much more faster process to create a new project. 16. Basic Sketch Structure: every sketch we will write or use is usually based on the following a basic structure. So the 1st 1 is valuable declaration where we defined valuable, well going, planning to use a to store value and, for example, over real. This is like the My Virawan in my bar. A To next is the set up function that is running only once and used for the system set up look. Function that is running forever is use the main A program, a code, and last one is the custom function A that we can divide A were called to a more reasonable block, something that is very useful while handling a larger program. Let's start to zoom on each one of them. 17. Variables Declaration Introduction: in almost all program, we will probably need to store value, do some calculation, try to access specific be numbers in albarino in more for that, we can declare storage location that our court valuables and we can access them using names . Let me take, for example, they start button variable that is equal to two. Assuming we know that in the physical circuit we connected some external bottom to dig ital pain Number two inside are doing no. Now, using this viable, we can access the status off the button everywhere in the program, let's say in the same project or in another project we decided toe physically change the connection off the button Topi number three. So instead of searching the whole lines off court, we can just change it in one single line in the valuable declaration. Now, before we can use available, we need to declare it so they are doing a platform will be ableto allocate the needed memory space. The way we declare the new viable is pretty straightforward. Choosing a data type and the unique viable name the data type define what kindof information we can store in the viable looking on the list of arable here we can see different type of favorable. Some of them are integer, some of them a 1,000,000,000 Charlie and the one. One thing that is important to remember is that the Arduino code is case in city and this is relevant. Viable name will see that also in function, name and more. 18. Variables Declaration Data Types: Here's some basic least off the most commonly used data types. The 1st 1 is Bullen, where the size off that valuable is only one single bit represent a two state true force, very useful in the code that we're going to develop. The next one is bite used to hold positive number from 0 to 255. A. Next one is a child. Type is the same is bite, but it can old. Also negative value the digital. The other type is one of the primary valuable that a type for storing numbers. It can be used to stole a numerical value. Between this. A long range other data type includes 30 Beat Longs, which is the big brother off the Inter Joe in the last one. Here is a floating point number. Express is the float data type that are capable of expressing fraction off a number. Using it is the symbol point viable? We behave in a certain way based on the properties off the data type. Okay, it's can be a inter jail long challenge zone. In addition, by using valuable qualifier, it is possible to modify the baby off certain valuable. For example, numeric data type are available in two options. It can be signed or unsigned on sign. Valuable will always contain positive value, while signed valuable can express number with a negative value. Usually most data type default toe sign data types but can be changed using the unsigned valuable Qualify I'll meaning making them to stall Onley positive value. Now this qualifier is useful for increasing the positive range off valuable or for indicating toe the reader that the value expected we never be negative. So in our example, by placing the unsigned keyword in front off the integer viable declaration, the valuable marks counter may now only stole positive value in the range off 0 to 5535. Another type of valuable qualifier is the constant valuable qualified that makes the value off a valuable A read. Only that cannot be changed. Once the value has been assigned, we use the constant key would at the beginning off the valuable declaration toe define available as a constant value to prevent us from changing by mistake. The valuable value later in the code, for example, this is useful if we know that pin number off the Blue Laid will never change. If we attempt with sign a new value to the constant valuable a blue led, we will get a compiler Llevo doing the verify process in addition to user defined, a constant viable what we saw before they are doing no development environment used its own pre defined constant. So the 1st 1 off this constant defined the Boolean Logic estates based on a logical troop table using two states. It's gonna be true or false. The first condition is is usually defined as being zero or something like off on the other end. True is in many ways anything other than false, so it's gonna be true or could be one. Unlike I was either a constant, A true and force always appear in lower case. So please note that next one is pain level a constant that defined operation off a digital pins as either input or output. Using the Pena mode function, you can see that is an example, so we are setting a P number. 13 is an output right now, using the constant a output. All defined the pain levels as being high, although status equivalent to setting the bean states toe five volt or zero vote something that will use a lot doing our programs 19. Variables Declaration Naming: Now, some of the names that we may choose for viable declaration may not be the most readable, which is why many programmers are doing oppo comments have adopted certain naming a guidelines or conventions, so naming convention are not specifically required when defining our own unique names. But they can make code easier to read. For example, we can have valuable names with multiple worlds, but because we cannot use space inside our viable name, we might want a way to separate each word toe. Make the name easier to it. For that. It is commonly accepted to use at the convention, known as the CamelBak notation, meaning the first letter off the first World will be lower case a while the first letter off each subsequent sward will be capitalized with no space say between each world. Okay, so you can see Blue Power led blew the first word. It's a lower case, and then the next world power. It's an uppercase and so 11 thing to keep in mind is that extremely long names start to become harder type over. Then, over the game 20. Variables Declaration Scope: so far we saw how valuable are declared. Now let's discuss on the location off the valuable declaration. The location off the valuable declaration in a sketch actually determines where that valuable it can be used what is known also as the valuable scope. Now we have two types off viable scope global valuables in local valuables. Global valuables are declared outside a specific function at the beginning, off the source code. It can be used by all function in the sketch, regardless off location. And this is very useful. If we would like to use the valuable value, they cause different function. We will use them a lot to define AP numbers, set up it racial or define constant so that all function in our sketch can use the same value. Now, if the available are declared inside a specific function, it will become a local valuable and will be unavailable outside. That specific function will see later that some local viable can also be used inside. What is called four loops is a countess where only that statement can use it and not the rest of the function. We'll see that later, so why not toe declare all viable is global, instead off using local valuables. Well, using too much global valuables make it more harder to read and understand the software, since any line off code anywhere in the program can change the value off the valuable at any time. So in that case, to understand the usage off that global valuable, we will need to analyze the whole program, so we need to balance between the usage of global viable and local valuable. 21. Setup and Loop Functions: set up a function is the first function in are doing a poor gum weeds and it's one only once. It's all purpose is to set up the old Widow device, assigning value and properties toe the boat. So, for example, we would like to set a specific AP number thing Toby Digital output. So we will do that only one time in the set up function. The second function loops a make. It's possible for our sketched one continuously, and it will begin just after the last statement in the set of function has finished executing when they are doing No one's a sketch. It started the top off the off off the first line and then move a move its way toward to the button. This is called Pogon Flow and Affairs to the order that the statement are executed one line after another. Looking in the simple Code Hill, we're starting by setting peanut butter, teen toe, high value, waiting for one second. This is the delay and then setting P number 13 toe a low level and then again waiting for one second and look back and start all over again. 22. Custom Functions: we saw to a function set up in Loop that are part off any skate ship or gum in general, we can right all our their program in those there to function. And everything will be just okay, However, when our project is becoming more complicated and there are more lines off court that are needed than putting everything in the loop function is making our program unreadable. Very hard to debug, unless usable for reuse in other project. So in programming it is a common practice toe divide. Big task toe smaller dusk using function. A function is a block off court that perform a specific task that is repeating in a program . Now, instead, off writing the same code all over again, we can just call the function name. Let's see how we define a new function. It is very easy. Starting at the beginning, we specified the function data type in this case, integer following by the function name. In that case, my function it the next will be permitted. We may or may not passed to the function curly braces required to mark the function body and, of course, the block off cored that is doing something in this specific case, this function is getting the value and X, and why calculate the sum and return that as a result? So if you go into the loop, a function above, you can see that we define some barometer that is called some and we call the new function my function with the valuer off four and 27. And, of course, dysfunction will calculate that, and then the value 31 put it in the digital. Some thats all isn't an example off creating custom function very useful while creating sketch. 23. Operators: operators a special characters and used to perform a specific operation. Now there are few types off operate. Oh, the first category is arithmetic operation really straightforward, like ending substructure, multiply and divide. Next, we have compound operator that are doing arithmetic. An assignment altogether competitive and logical operator. Very useful for building control statement and will you will see some example later on. Okay, don't worry. We'll use some off them doing the project that we're going to build. 24. Control Statements Intro: to really start building more complicated code. We need to use control statement now control statement and enable us to specify the flow off our program. Using them, we can make decision in specific location or to perform dusk a repeated Leo to jump from one section off court to another one. There are two kinds off statements available in arguing for controlling pork and flow. The 1st 1 is conditional statement that make decision based on a condition is true. Over there we have the FN else and switch statement. Next one is imperative. Statements that perform block off code a certain number off times or until a condition become false. A interpretive statement include the full and while a statement. Now let's start to see each one of them. 25. Control Statements: if else: if else statement is the simplest off the control structure and it is among the most commonly used method for decision making. The basic syntax is as follow a now one example. We're checking if my counter is equal to 100. If this is true, then the lines inside will be executed. And if the condition is not met, then we have the options to use another block off court under a els. In addition, the condition itself can be a combination off several sub condition. So as you see that this is simple and state a forward control statement, a very common useful if statement is to with the state off a digital or analog pin and perform in action based on the status. So in this simple example that reads the value off push buttons which connected to a specific PIN number hey, that we have in the switch be invaluable and then assigning that value toe the valuable let's which and then test the condition. If let's which is equal to the constant high meaning someone is pushing the push button, then it perform a block off code change. The state of the digital painter Tinto high using the digital right function which would have the effect of turning on a the lead on their doing no interface a boat and then wait for one second and right again to dig it a letter teen the value a low and turn off back again the l lead. One important remark liked weighed on FNL statement is to be careful from some common mistake and where we use a single equal sign in test statement, which means make equal toe instead off double equal sign which say test if this equal toe Okay, so please note between them, you should use the double equal sign. 26. Control Statements: switch: the switch statement is more complicated. Version off the if statement as it can execute one or more. A block off court, depending on a range of conditions, probably will use that in a more complex A program. So if statements allow us to choose between two options true or false, when there are more evident to option, we can use a multiply if statement all we can use the switch statement eso switch. Allow us to choose between several options. The basic syntax off the switch statement is follow, meaning we have the switch expression and then at least off case, a constant case one toe, three and more. The number off case can be as many as we need, but each one should have, of course, a unique, constant value. This is a simple example where we test the condition off some interview available called power level in case the power level is equal to one, then switch on only one lit in case the power level is equal to two dance, which on two leads and so on. Now, if there is no Met shake with some constant expression. The statement associated with different keyword is a executed 27. Control Statements: for loop: four loop is an interrogative statement that allows toe repeatedly execute lines off court in a loop. Ah, a specific number off times four loop is based on a counter or a specific valuable that is incremental did. Each time the loop is executed repeated the basic syntax for four loop will be is follow. The follow up begins with three statement that include valuable declaration, conditional statement and incremental statement. The first is the counter valuable declaration and it is run only once the first time through the loop. The second statement is the conditional statement using comparative operator, just like we will use in if statement and it is destined each time to the look. Now, if the condition remains through the court closed by the coldly braces will be executed. If, however, the condition return false, the follow up will and the 3rd 1 is in is being used to increment the counter available each time the enclosed block off coat is executed. Let's say we want toe blink lead three times quickly so we could use the for loop similar to the following code. Now, in this simple called the first time through the follow up we declare an inter jerry top valuable that will be uses, indexed or counter and assigned the value zero. So in this statement I will be equal to zero Each time through the loop, the conditional statement will be checked to save the condition remains true. So in our example, it will check if I is less an equal toe value tree meaning turning on pin 13 waiting for 300 milliseconds and then turning, being tilting off again, waiting another 300 milliseconds now each time it would a loop. After all the statement within the Kohli braces have been executed. The valuable I is implemented using the increment ID statement I plus plus Okay, it's also will be a dick element in meaning I minus minus. Okay, we have you have several combination to use this index, so counter 28. Control Statements: while/do loop: you will see that full statement is fairly common toe a program melt. But there are also other way to structure its relative loops. A The wild statement a while loop is usedto continuously execute the statement. It's so long as the condition remained true. Now the basic syntax off the wild statement looks like the following with the while and some condition and then statements inside. Like the four statement, the wild statement evaluates the condition before executing at the block off court so that if the condition is not met, the could we never learn Now. Sometimes it will be needed to learn the called A to least once before evaluating its condition. And for that we would use the do statement. They all do look so the do loop is like a modified while statement in that it's execute a the lines off court and then tests for condition at the end off the loop rather than the beginning before deciding to look to the beginning again or not. So were the following syntax in pretty straightforward. We have the statement and only the checking off the condition at the end each time, so if I will compare a simple example off while for a while. So the 1st 1 while if the condition is destined before the court. Okay, so I'm testing. If counter is less than 50 if they and only if this is true then I will execute the court inside on the other end The do while the condition is destined after the code s so we know that the code will run at least one just another volley of aviation off the while a statement. 29. Using Libraries: one of the greatest things in Obree no development environment that a. I d. Is that it's provide us an easy access toe, very large amount off off the shelf, ready to use function that are grouped a tow libraries. Now libraries are a collection of court that make it easy for us to connect it to a sensor to some, display more duels and and more meaning someone has already done the hard work and created function toe interact with some external component. It can be related toe communication, like Internet WiFi or how to store information. When an SD card display text on LCD display and much more. There are hundreds off additional libraries available on the Internet. A for download now Let's see him. The library manager options that we have inside the How do we know a. I d? Okay, assuming would like to add some library in our boredom. So we already so that before we going into option that is called sketch under that to include library and choose something, for example, let's say I would like to choose the poem options just taking that, and it will lead the new line with the world, including the name off the library. No. In addition to that, you can go again to this the same options and go into manage libraries. And over there you're getting some nice options. Toe filter A libraries based on topics. So I'm going into a kind of topics can be created, for example, by communication. I would click on that. I will get all kind off available libraries related to communication, some off them, all elegy installed. It's part off the built in. Do we know I d for example, data on it. A library being used to a used are doing. Return it, Terry. A Bordeaux shield. You can see some short explanation about that. If I will school down, I will say a long list off all kind off a library related to that topic. Communication that I can use neutralizing my poor dumb. Okay, very useful. Just under one category, you can see a long list off libraries if I will go to another one, for example to display. So there is a built in a library for way for we're using for all city that is called the liquid crystal. We will use some off those libraries. Not in this specific course in next levels. Okay, But just for your knowledge, how can you find it and ed that to your problem? 30. Comments in Code: the last subject I would like to cover is related to Ed in comments in our code. Now comments are used to document what's going on in a poor gum for anyone leading the code and should be used any time. We wish to explain what a poor gum Oh, maybe a specific function he's supposed to do. Fill free to use them throughout your sketch, even if you think that they are not useful right now. Bishoo. They will help you to understand what the hell have you done like just a week ago or were months ago in your sketch. They are also useful for disabling parts off a sketch for testing and debugging. We can quickly disable specific line or a group off lines and see what happens. It's also helpful to make a change in a part of the code, but leave the old code in place using comments just in case we want to use that old a co a code again. Now there are two basic types off comments, a single line in multi lines for single line comments. We use the symbol with double forward slash it for multi lines comments. The lines are enclosed within the following a symbol. They are used to mark the beginning and the end off the block off comments. Okay. Very simple and very useful to be used in your sketch. Okay, that's all for this section. Recovered many subject, and now we would like to start practice, some of them a well, creating our first project. 31. Learning by Doing: I assume you already know it. Learning by doing is probably the best way to really shop our understanding and skill. We just can't replace experience with books. If you would like to really learn something, then right in the Hill World Building and are doing a project can be a challenge. But in the same time, it will be also really fun and satisfying is, well, building a walking electronic system. So doing the next section, we will mix some basic theoretical background with an actual project will beat, and this will be the way to learn by actually doing in front. 32. Our Arduino Project: so to practice and lend some of the basic element in order. You know, we are going to build the following project in the three main steps in step one movie lead a six led and to a simple dig ital sense. So as a push button in Step two, we will lead a two under look sensible toe control the led speeding brightness in step three and we were lead emotion detector Looking on the circuit here we see festive for the Arduino Uno board and many external component connected to it. Like the six a red led the two viable resistor. An emotion sensor on the left side. This project will help us to understand the usage off digital input, digital output, an analog input, all connection between external component and that will board is being done using a special prototyping board that is called bread Boat. We will soon cover how to use this bread board. It'll before we start for building our project and wind. This is the least off quite component and nothing is there really an expensive piece of equipment. And if you already got some Obree no started kid as I'm is a mentioning the in the first section. Probably you are fully covered, but please check and verify that you got this list. 33. Breadboard: In order to build circuit, we have to connect a second component together. And a great tool for this purpose is the sole Derlis Bread Board. No, probably you already got it. It's part off the Arduino starter kit, So just a check. A bread boat is a simple prototyping plastic baseboard that easily allow us to wile up simple circuit without having to solder together parts toe a custom printed circuit board. They come in many size shape and Coehlo. It is important to understand how a bread boardwalks so that we can use them more effectively. In our project. The key to using bread boat is knowing how the socket all connected. And this what I'm going to explain. First looking on the blue and red lines on the left side, the run recently, the pains that are part off those lines are designed to be used. His power in ground bus. That's all now looking on the picture on the right side. Okay, this is the back panel. All the red pains are electrically connected in the back panel and are used for providing power, meaning five old. All the blue lines are also electrically connected and are used for ground a connection because we we need to connect a circuit external component to the supply voltage and ground these long resent aligns off many holes are useful for providing supply, voltage and ground toe. Those external external complaint moving on all the vertically line pains are also connected in Hose it with a division in the middle to make it easy to mount a some integrated ticket on the bread bowl. If I will paint it on the screen and let me at some point to Okay, so this line he's used for ground this line is used for power. Okay, all those holes are connected. That's the beckoned view. Okay, that's the front fronted. Now, if I will connect some a component like is this toe? The way to do that is to connect it from here. Toe another location. Okay, Like it's connected over real because column number two and column number six are not connected. But all columns number two is connected to each other. Okay, As you see, it's connected as a one bus. So if I will take another component and connected to this point and take it, for example of a real then what I got is that those two, this one in this one actually connected in column six. As I said, all the whole column C is connected at the beckon, and this is the way to connect between AM component. And in addition, I can choose to connect this element to the ground by taking this holes and connected that ovary. I just connected that to the gun and I can take this component and connected to day power. I just created a circuit, and this is the way to create all kind off circuit using the bird board. If I will take some its integrated circuit, then the integrated circuit will be like, you know, some books and all the pains will be a line connected toe those holes in both sides. That's the way to connect some integrated circuit. Okay, And then, if I would like to connect to some pain location, let's assume I need to connect this pain to the power so we'll just take these souls and connected that to the power. That's all that's the way to connect things. And we use that a lot. Looking on some simple circuit example we are taking ground and voltage power from their doing. No board toe the bread board. In addition, we can also connect the lines below to the girl and power to extend the available place to connect power and ground. Next we have the led one side is connected to the ground and the other side is connected in sale to a resistor that is connected to the dig. Ital Pain number three. In that case, we go to simple circuit Albarino led and some Resistol. Now some small remark. If you look at the fundamental understanding off electronic circuit like what is a voltage or power? What is resistance or current? What is a circuit and so on? I strongly recommend to review my previous course. That is gold, the teary beyond electronic. Okay, that's will provide you some fundamental knowledge about electron ICS. 34. Step 1 - LEDs Test and Animation Wave: way would like to start with the first step. They were building the project and there are few learning objective I would like to cover. So in this section we will learn how toe while simple component using a prototyping boat, a read digital input from simple switch device use. Pull up and pull down Resistol, a right digital output toe led component and lento handle switch bouncing. We'll do it off that they were developing a software sketch using global and local viable. They set up in function building a new function, and at the end, this case will control the all are doing no platform. 35. Step 1 - Project Building Blocks: the following diagram is the project building blocks for this step in the middle. We have they're doing aboard connected to six led as output on the left side, we usedto push button as input. The first push button will be used test that the old leads are walking by telling them own enough. The second push button is one some short animation wave across the six led. That's the overall plan, and let's start by wiring the leads, a tow the doing aboard. 36. Wiring LEDs: led our one off. The most used component in many project for many good reasons and is, you probably know, Ellie distant for light in meeting a dialogue like old dialled Component led allows current to flow in only one direction. So leads I'll polarized component, meaning. We need to carefully connect them in the right direction. The positive lead is called and they are no, and the negative lead is called the cattle. Another way to find that is to look on the lens off the two leads. The shorter lead is the cattle, meaning the negatives lead. Now because current flow from positive to negative the arnold off the lead should be connected to the current source. Meaning of the five evolved the heater signal in this case, and the catheter should be connected to the ground. Another thing that is super important is to use, resist or as current limiter, existing must be placed in serious on either side off the led. Now, as resistible not polarized, we do not need to worry about the orientation Now. The logic is very simple. The larger Resistol value, the more it will restrict the flow of current and the demon of the lead will close In our scenario, we're using 220 AM Resist looking on the diagram here each led is connected on one side to the ground and the other side toe exist. So that is connected to a specific dig. Ital pain in the, you know, platform. This is a complete ticket and in total, we have, like, six separate circuit for six. Led now later in our sketch will set up all the six spins Toby output and 10 the lead on enough using specific software commands. 37. Reading Digital Inputs: next step is to read the little input. Now, what is exactly the motivation? Reading the little input will help us to interact our albarino with the extent of the violent in ill time. In our case, we're going to use very simple dig ital essential that called push button. Now just understand the simple operation off a push buttons which a normal situation meaning nothing, is pushing the button. It will be open cutting the circuit. When being pressed, it closed the sick it So in that case, we can detect such a scenario using a digital input pain and then they get something to read the status off a button. We first need to define a specific dig ital being as input in the set of function. Next to discover whether the button is pressed, we will use the digital read function where pain is the digital A B number to win. However, one thing that is important toe ed toe the sick. It is something that is called pull up or pull them Resistol. Now let's understand why they are needed and how to use them 38. Pullup Down Resistors: looking on the simple circuit scenario. On the left side, we have push button switch that is connected to the ground and then toe some digital input being on the other side, connected to their doing. No. Now, while pressing the button, we have a closed circuit, so they're doing a Wilhide zero volt. As soon as we leased the push baton, something strange will happen. The input pin we would like to read is essentially connected to nothing. It's floating, and because the pain is not physically connected to zero volts, five world reading could cause unexpected result. So the solution for this is very simple. We will use a pull up or pull down resistor to set the default states off the input, the main usage off a pull down resistor. It is to set the default state off input pin to reserve of old. Now, 10 killam is usually a common pulled down resist off value. We use that in a well circuit. Now I understand the logic. Consider what happens when the button is not pressed with the pull down with this during the circuit. Okay, I'm not pressing the push button, so it's not connected between the two point in this case, they input pain okay, will be connected. True, a 10-K or more resistant to the ground. Now, while the system will restrict the flow of current, there is still enough current flow to issue that the input pin will need a low logic value , meaning something that is closed. Zero oval looking on the same diagram. But here the button is pressed, meaning they input pain is directly connected to the five volts through the baton. Now, in this case, the current is too options. It can flow through an almost zero resistant pet toe, the five old side. We can flow through high resistance, but to the ground side, if you remember a little bit electronic background, arm blows and the power equation estate that current will always flow the pet off the minimum resistance in the circuit. In this scenario, the majority off the current flow will go through the baton, and a high logic level is generated on the input being off the Arduino because that's the path off the at least resistance. Without big surprise, we can also use pull up resistor instead off pull down resistor by connecting the Resistol toe, the five vault and by connecting the other side of the baton to the ground. I mean, switching between the ground and five volt in this set up. The input pins needs high logic value when the baton is not pressed and the low logic value when the button is being pressed, summarize, put down and pull up. Resistor are important because they in true that the button does not create a short circuit between five World and the ground when being pressed, and that the input pain is never left in a floating state. 39. Final Circuit Review: Okay, let's use the freezing to a to to see the second that we got so far for the step. I just want toe remind you that you can download a original sick it files from this chapter so you can play with that yourself up in the freezing open there, then the template file and they play with that now, looking on this simple circuit. So we have that doing over there the bread board with all kind off external component, the external component that would like to use our six led into a push baton and some Resistol. And we live that the resistor that is connected in serious toe the lead is being used toe limit the current, and you can see also the value off that Resistol. And of course, the other side's being connected to a specific pain number. So in total, have six, while connected with six led. We also learned that the one side is the cathode and the other side is the entitled The cathode meaning the short side is connected. Toe the gown. And remember this all result a line is this is I was gonna be coming from the Al do we know ? You see GNT over real supplying us ground and supply us also a five volt power. Now, in addition, we have the poor, the to push button, this one and they are the one. The push button is connected using a pull down with this. So this is a pull down. Resist. Oh, if I would click on that, you can see the value off that resistance. 10-K A. On now, the idea that I'm connecting it is this. Tow it to the ground, okay, over Real and then connected that one side of the bush push button and the other side toe five toe the five volt power in the middle. I'm connecting. That's the yellow while. And this is the input Pena would like to measure. Okay, at the end, it's connected to some pain in their doing that will set up is an input. And I mean, it's symmetrical. So we have pulled down. Resist also for this push button, that's all very simple. 40. Project Review: Step-1A: we saw a different thing. Software that help us toe design a circuit using the software in a very nice A organized way. Now let's play with the actual Outworld and that we're for this first faith. So we have the bird board below and all kind of component connected over there. Six. Led led to a push baton, and everything is connected to that. We know right now they are doing is connected using a USB to my computers so I can download and software sketch to this ball and in the same time, supply power. Tow this boat and I can see the small power lead over real meaning at the boat gets getting power its own. And every element is connected, as we saw in the circle design with the relevant day P number and so one just small remark . Maybe you noticed that the six led are not actually connected in a nice older over here. And the reason for that is that I'm utilizing only a pains. Digital paint that support PW pulls wide modulation, and that's like with a small a tilde that you can see close to the P number we'll discuss about it very soon. Now let's play with the circuit. So the first thing I'm doing I'm uploading the soft Well, so I'm going into their doing No i. D software opening sketch dedicated for this face and upload that to the board. We'll see in a very fast manner of the Arctic sticks that are being being run. And that's all it's being elderly uploaded to the bold. Now let's taste it. If I would press on this button, that's the test button. I'm expected to see all six lead to being a big on for one second. OK, click on that. Getting one second for the old Led. It is like a testing baton, and the second button is for getting some nice A wave of animation, okay, going back and forth very simple. Just to show you something, if I will prescence on that right now and in the same time, I will go and click reset. Okay. They are doing off course, will start from sketch, and we'll run the program from the beginning, That's all. OK, that's for step number one. We land use digital input and output the output is using led that are connected with a resistor that are being used to limit the current in addition, way connected toe push button as digital input, and we're triggering some event based on that action. Now let's leave you the sketch itself. To understand what, how, exactly, we achieved a that scenario. 41. Sketching in Code: Step-1A: Now let's see the sketch used to run this project as we saw before. Always. We're starting the sketch with some comment about the goal of the function off the sketch. In that case, we're talking about step number one A and the idea is to use to a bottle. One is for testing the lead and the other one is to run some animation with We're utilizing the digital input and also the Gittel output now image problem. You will see some sections related to global valuable Declaration. In our case, we would like to map the physical sense of connection to the Arduino digital pains according to our project s So it's going to be constant interdigital valuable that I'm calling the 1st 1 test button and it's equal to two meaning p number two in the same. A. True for the way they're button just different. Been going next, we would like to make a the six lead physical connection to the Arduino digital pain. Now I have 66 point. So one option is to create, like six different viable I can call it lead number one and lead number two, and so on in that case to make it move easy. I'm using the capability to create in a way okay, that's the name off that valuable lead pins it's in. It's in a off into jail. In that case, it's in a day off. Six integer value. Now the value that you can see ovary. That's the P number that are being used to connect the lead. Meaning, if I'm looking in this location, this is the key. Number three is being used for lead number one if I'm looking over real. So this is a pain number nine being used toe lead number four. I'm sure that you remember that in every sketch we have two basic function. The 1st 1 is called set up function, and it's being run only once. And the other one is look, function that is running all the time in a look. Okay, so the main code will be under the loop and summit initialization will be placed under the set up a function. So in our case, we are using a function that is called being mood to set up each digital Penis in Porto are put so the test button will be set up. Is an input. Okay, We would like to check if the bottom was pressed a the same tool for the wave, but we're setting That is an input. Now, for the six leads that are connected to six pins in our world, we know we would like to set up is an output. So the easy thing to do is to use some follow up, start from zero until five in each time, and each time changed the index in the way and set up that as an output. The next main function is called Look, I mean, most off our good will be placed over you. Now what I have done toe would use the complexity off the loop is to create is toe customize function that I'm running inside the look. The 1st 1 is checking the test button and doing something if if the test button is being pressed and the 2nd 1 is checking the wave button and also doing something If the wave bottom was pressed and because this is underdeveloped, planning goes to a function again and again now lets you manage customize function. Okay, let's review the first function educated that is called check tests battle. So the first thing that we can say that this function is not returning any value and that's the reason I can see a the saved would void and it's not getting any power matters. Input now moving to the first line What I would like to do is to a lead the status off the test button right now. So I'm utilizing a function that is called the Eat Al Aid. Okay, since sending is a problem, it, er the pain number that I would like to read. And of course, we are sending the test. But in this problem, it'll I'm and I will get the result. It can be low. Oh, hi. Now, using this operator, I'm comparing the result. If it's equal to high meaning, the button is pressed. In that case, I would like Toa 10 own or the six led, And for that I'm utilising the full look starting from zero until five. And here I'm utilizing the dig Ital right Funk Jane instead of Digital agreed and is an input at the same time, providing which may be number would like to write and the value that I would like to write inside, and each time this index will be changed. According toa this photo it will start from zero go toe 1234 and five And each time a different index will be provided. And I will get a different value from the lead paints A As you remember, we initialized the sled pains over here. Okay, so according to that, I will get the relevant a pin number and said it toe After that, I would like to wait for one second. So amuse utilizing functionaries called delay the Pomatter in Milli second. So that will be 1000 really second to get one second. And after finishing that, I will do the same just turning off all the six lead. That's what the check test button is actually doing. Moving on to the Czech Wave button. The check wave button is not returning anything so I can see the void over. It's not getting any parameters, but here I'm using digital eight function. I'm reading here the wave battle as an input and the same logic. Um, comparing that to hide to save the button is pressed in that case, what I would like to do Israel is to run some a wave or fairly starting from the 1st 1 until a lead number six and then start from them. Let number six and going back to one. So I'm using again the full loops using the IRS an index eso The logic is pretty simple setting using the digital right, the relevant led high waiting a 400 really second and then then that two off the similar the same elect and doing that again and again running from the first lead until the last lead. And when we finish that we're doing the same but and different order. So here I'm initializing the index to five and then reducing the index each time. So we'll get that as a wave just the other side. Now there's something I would like to improve in this court, and this is related to the Czech test button. What we ever ovary is that you need to a hold the test button, and then the old led will be there on a soon as you release the button, a the old lead will turn off. In many cases, you would like the user to only press that button on and off okay, without holding this battle. And this, what we're going to do in the next sketch as an improvement will call it step number one big. And we learned how to handle this situation. It's a little bit more complicated. Important toe Close the issue of how to read information from from buttons. 42. Handling Switch Bouncing: as I say, we would like to improve our called and in that case led the user to click only ones it will tell on off toggle between them. So we need to detect that the button was pressed and tackle the led on and off from the last state. If it was off, then with any tone, if it was on, let's stand that a off very simple meaning in that specific point where you see the Blue Triangle, we will know that the bottom was pressed. However, we need to handle some phenomena that is gold. Switch a bouncing and let explain the tissue and how, exactly we can solve that while working with buttons. We just can't look for the value of the switch toe change from low to high. Oh, from high to low as we need toe handle a problem that is good. A switch bouncing. Let's understand the problem. Over button are mechanical device that operate much more slower than I were doing. No system. In other word, when we push a button down the signal, we will lead. It does not just go from low to high. It bonds fluctuate up and down between those two states for a few milliseconds before it will stabilize. Now, doing this bouncing time I will program may translate that to several event off button press. And actually, it's only one press. The good news is that we can easily handle that using a software code, and it will be a good example for building a little bit more complicated sketch. Now, before jumping into the sketch, it's itself. Let's understand the logic off what we're planning to do. The following diagram present the status of for Button doing one single event off for user pressing this button now, as you see there too short period off bouncing when it is being pressed. And, of course, when released, the software solution for handling switch bouncing is a little bit tricky, but it actually based on some simple logic. What we will do is hold the last baton state in available in a new valuable and keep reading the current a button value all the time in case the current value is now high, meaning someone just pressed the button. Then the program will wait for five minutes, second to let the switch status to stable and only then we will need it again. This will help us tow Avoid the bouncing period, solving one part of the problem. Now, off course, the current value will stay high as long as the button is being pressed. Okay, even if that for short beard. And also we bounce again when it is being released. However, we would like Toa Tagil our leads only one time at the starting point. And that's all. This is why we check our two viable Caryn Button state in last button state. Now think about it for a second. What condition? We can check to assure that we will only Tagil the led only ones. Well, the condition will be if the current is now high and last was low. That's the conditions that will check. Let's see that in the final sketch result. 43. Sketching in Code: Step-1B: looking on the sketch. The improved sketch. Okay, call it Step one B that now we are handling the situation that I would like the user to click only ones on the test button that will tug alone enough. And for that, we need to handle so which bouncing. And this is what we are going to do in this problem. Under they fireable declaration, I added three more valuable. The 1st 1 is like the flag off the status off the led. And it will present the state that we know if the leads are right now on off and to an additional bullion valuable. A 1st 1 is the last button status. And the 2nd 1 is the chi button status. Okay, we initialize them too low a value it when starting the program. If I will school done below, then under the set up function, I didn't change anything in the same function and same goes to the loo function didn't change anything. I changed the content off the check test button. A custom function. Now let's review a the new core that I edit under the check test button. Maybe I'm looking that for the first time, it would look a little bit complicated, but I'm telling you at the end it's It's a simple logic, the first line I'm updating and leading the status off the test button, using some function that I will discuss in a minute. Assuming that I have this status right now in this valuable, I would like to verify some specific condition and if you remember the diagram, so that's the condition I would like to test. If the current is high and the last is low, the current bottom is high and the last button is low, meaning. That's the first time that the bottom was pressed. In that case, I will Tagil at the Led States. That's the line that will switch the value off the lead zone, meaning if the leads on flag is low, it will switch to high if its height will switch to low. And, of course, I'm updating the value of the last button from the car in bottom. So it will be always a line and writing that using the digital right function and updating the led using this flug. Now let's see how, exactly I'm leading the right value off day off the button using this funding that is called the bombs. Okay, so the D bounds function is actually the function that is providing the delay that will lead the stabilize a state off the bottom this function, the bounce is getting to Pala metal. One Parmenter is the P number that you would like toa test and the last state off that specific battle. If I will school little bit up, then you will be able to see this new function d bounds its return a boolean value and it's getting toe perimeter. As I said, the button pain is an integer and the last value off that pattern is a bullion. No, the first thing that I'm doing, I'm reading into some local viable that is called current current value of the this button using digital it function if current is, is not equal to last a meaning there is some change. It will wait for five millisecond using the delay function and only then it will lead again using the digital aid reading in the again. The volume put that in in the current local viable and returned that the idea in this function that it will retain that stabilized a valued of civilized states off specific battle. Okay, I hope it's us toe confusing and you got the idea. Now let's see the result. Okay, we change the software and now would like toa upload that and see the result in the actual A project. So I'm clicking on verify, of course, every time changing something, and I will upload that to the Arduino and let's see the result. 44. Project Review: Step-1B: Okay, So after uploading this new sketch with the new code into that, we know now we know that we can go into the test button and click on that only once every time without holding this button clicking each time it will switch the led on and off. Okay, that's a behavior that user will expect usually while pushing a push button. So the software for Wendling this switch the bouncing. It's going to be useful if, for any project that you are going to use today or in the future. That's all for this step. Step number one. And we learned a few things that are important. How to aim. Send digital output in tow led device. How to connect those led using a sister, how to read digital input from an external component like this push button. And how to handle some a mechanical limitation off push button like this, which the bounce and handle that in a very nice way using a software. And that's all for this step and let's move into the next step. I think more on a low capability into our project 45. Step 2 - Control LEDs Speed and Brightness: remember we divided our project in few steps. In step one, we handled digital input and output. And now in step two, I would like to start using analog input that are equally important as Decatur input. So in this project, we will read analog data form a valuable DeSisto. But it's called Put into Mento. Normalize the reading Toe the relevant range so we can use it utilizing the serial monitor options for helping us in testing our program and at the end simulates a analog output using a technique that is called pools wide mood relation. 46. Step 2 - Project Building Blocks: looking back to our project Building blocks Reality have that We know a boat off course six led and to dig ital! Let push button being used as input to the Arduino. Now we would like to extend the input capability and ed a too valuable resistor as analog input a toe control the brightness and speed off the six led. Now those valuable assistance would be connected to the analog input in the albarino. 47. The Variable Resistor: Resistol are one of the most common component it we will find in any electric circuit, and mainly because they are really useful. And the main function is to limit current flow and said voltage levels within a specific circuit will be used fixed sized, resistant it to connect The led to the Reno in a safe way. Now, in addition, toe fixed Resistol there also a valuable DeSisto, or Resistol, that the resistant can be adjusted by a physical rotation. A one community type off valuable DeSisto is the point into metal, and we can see in the picture on the left side that there are many types size and shape off a potent issue metal. But the function is similar. Now let's zoom on one of them. Such a potent issue Metal is the pain connection one in the centre bean and one on each site. When someone is turning the shaft off the valuable resistor, it's actually increased the existence between one side and the center and decrease the existing between the centre and the opposite site. So if we will connect a such valuable resistor as analog input toe dad, we know we can get different leading when the user manually change it. In our case, we can use them to adjust the speed and brightness off the led. Now the way to connect it is really straightforward. One side will be connected to the voltage source. It doesn't matter which side it's symmetrical. It can be five Balto other voltage level. The other side will be connected off course to the ground. Zero volt toe. Provide a reference for Dutch and the last one, the middle terminal, will be connected to the agree no analog input pin. Let's see how it is connected in the project. A circuit design. 48. Circuit Design: looking on the circuit design I ended is the P I. R. A model that you see here on the left side and the connection is pretty simple. The three connector on the P A. R s. So the 1st 1 is connected to the ground and the other side is connected to the power and the middle one is connected using the bird board to dig ital pain a 12 Okay, that we will use to read the value form the P I. R sensor. Very simple. And that's the final bottle that we're going to use in this project. 49. Step 2 Circuit Design: okay, back to the freezing A tools. And we will keep updating that according to the step that we are right now, just to remind you that you can download this template from the chapter that we're seeing right now from the download section in this step, we had a two additional component. That's the two potent you met over there looking ones. One potency matter. So you see that we have three pings below. One side is connected to the ground. The other side is connected today, a five volt power and the middle pain is connected as input to the analog, a input pin in the albarino, and the same goes to the other potential matter. Each put into matter is just being used toe to do some other functionality. One is being used toe control the brightness off the lead and the other one is being used to control the speed off the leads. When were they are running in the animation wave? That's all very simple steps just ending it to physical, viable resist ALS that presented by the to put into matter 50. Reading Analog Inputs: reading analogue input A will help us to better interact our albarino project with the extent on environment around us, as many Senso are providing on a log output when measuring some properties say, like this stance, temperature, speed, light, brightness and much more. In our case, we're going to use the potency, a matter we just saw as a simple on a look Senso to start learning how to read analog input . Okay, so for reading in analogue input, assuming all out with eggs aladi connected, we should perform the following steps set up on a look Penis input. Well, this is not needed is the six analog pains are only used as input, so we don't need to do that. Digital means something is ideal own in off, but analog means it's can have a continuous range off value that we know has some built in model called a D. C. On a look to digital converter that convert the voltage seen on the pain to a number that can be used in our program, this model will return a value between 0 to 1000 and 23. This is like 10 beat, so zero voltage will they will be read as zero. A number and five voltage will be read as the maximum want 1033. So we will use the Anil agreed Function to read the analog sense of value in voltage. Translate that to dig ital value and store it in an integer valuable Toby used later in our coat. The digital value range that we will get for manana looks. Enso should be tested before being used, and the easy way to do that is by using the serial morning towing and only then mapping the input value range toe the needed output range. Now let's start to do it in step by step. 51. Utilizing the Serial Monitor: we learned that the hard we know will convert the 0 to 5 analog signal to a digital number between 0 to 133. However, sometimes it is not that case, meaning we will get a different subset range between those maximum value between zero toto 133. We get something less than that. The main reason for this is that every sensor is a little bit different and will provide a variety range off voltage levels. The bending on what theyre actually sensing. For example, imagine it's sensible that generate value. Instead of 0 to 5, it will generate between one volt toe 3.5 foot. So in that case, one vote is an analog input should be represented by zero digital value. So in order to better understand the change off value that a particular sensor is providing , we will use the serial monitoring options toe, help us visual the value reported by the window, and based on that, we will be able tow, normalize the data Serial communication is used by two digital devices to talk to each other, and in our case, the USB connection is the single cook communication protocol between our bueno and our computer. We led used it toe upload our source code to the Arduino board. Now we can use the serial monitor, including in the Arduino programming environment Toe actually see the values that the window is reading from such external sensors. In our case, before using the potent you meto toe control another piece off Hardwell. In our project, we were print out the potency or metta range. Even if we know the expected result, a former potency matter because it relevant to another look sense so that we may use in the future. So let's move on and start to learn how to set it up and use it before we can use the sale communication. Walking with their doing aboard, we need to first establish the communication speed between the two device using the sale dot begin function, and we'll do it. It's part of the set up function using one line off court. What you see right now, sale that begin and some number inside the number is actually communication speed parameter measured in about rate where 9000 and 600 about is a common value that we should use for printing information in any location. I will code we have to function, sale that print and cereal that point Ln they're almost the same, except that the 2nd 1 will print a the information and we start a new life. Now in our case, it we would like to print the current value we got from the two viable Resistol and let's review the relevant cord and the actual result in our project. 52. Setting the LEDs Speed: Okay, Great. We used cereal monitor test Our sensor pointed the result it to our computer screen. And now we know that I will speed Senso provide value between 08 to 1000 and 33. Now, this process is useful for many other sense ALS. However, while using the built in delay function, speed will be measured in milliseconds and the elation is off course. Opposite more delay is less speed. Let's say that we would like that the speed range will be between 100 to 700 millisecond not between zero toe 1033. In that case, some range normalization or mapping will be needed. The good news is that there is some simple to use function that will help us to perform such mapping. Using the analog read function, we will read the value from the una loca input pain correlated toe the voltage I was Senso is putting out which in our case, should indicate the needed led speed and we saw that the value ranges between zero toe 1000 and 33 Now for mapping all normalize this range, toe, other range. We have a dedicated building function. This function remap and number from one range toe other. So actually it is one of the most useful function a for mapping sense of values. It is good map and use for input parameters. The first parliament is the actual value that we would like to map. The second intent perimeters are the original low and high values, and this is where the analog cereal monitor will help us to check the value coming former will send. So finally, the fourth and fifth parameters are the new low and high value range that we want to make up the original value. In our case, we just want to make sure the maximum speed will be 100 millisecond and the minimum speed will be 700 milliseconds. You will see that this is goingto be useful also for the second sense. So we used to set up daily the brightness because on one side, the Anil agreed retained a value in a range off 0 to 1000 and 30 tree, but analog right function that we were planning to use can only make a value from 0 to 255 . In addition, another thing that come up frequently is the need to re vests angel value again. In our case, speed and delay I'll opposite less DeLay is more spit, so it makes sense to reverse the range off value so that instead off out putting a 108 to 700 we would flip it to 700 to 100. And the way to perform it is just by flipping the last two value easy and various full something that is less relevant for our specific case right now but can be 11 toe other sense of types that you may use in the future. We saw that the Met function is useful for changing the starting and value off a valuable. However, it is not limit them toe. Only those value living value outside off the Met function may be useful if we only want to map a smaller part off a range off value taking. For example, the need toe ignore reading form, a proximity sensor that detects something that is maybe too far away or ignore a sound below some treasure level and so on. So if we want to force or filter the value toe very specific, limited range, we would use the constraint function. The same tax for this function will be a constraint and three perimeter. The first para matter is the value that we want to constrain toe a specific range. The next to Pala matter represent the needed many movement maximum value in that new range . Now let's say that after analyzing our data, looking on, the range is being returned by our sense. So we find that the minimum reported value averages on 40 and the maximum with around 1000 . We could constrain this value before a mapping them toe in your image. So taking, for example, the following code. This code will limit the leading toe anything between a 41,000 ignoring any reading that exceed this minimum a maximum A and then followed by remapping that using the analog value toe a more usable range off a 100 to 700. Okay, that's all that's the way to use the constraint. However, in our case, it is not needed. But maybe you will use that in others and so that you're going to use in some future project 53. Sketching in Code: Step-2A: Okay. So until now we learned a some fundamental issue related to connecting analog input into our you know. Now let's review the sketch the program I made to help us to move into step to Steptoe A In this step and the final Steptoe, we will control the lead speed and brightness. However, in the first phase, meaning step to a, we will first read analog input and from the to put into metal. And we just print the value into the serial monitoring and only in step to be, we will adjust again the sketch and actually influence the lead speed and brightness based on the selection of the Putin's you matter. Now let's review the actual court. So the first thing under global valuable Declaration, I added two additional available speed control being that is connected to a zero in the Arduino and brightness control pain is connected to the next one. A one. I mean, we have the to put into metal connected to two analog pin. Okay, going next under the set up function, and I ended two lines. The 1st 1 is initializing the sale communication to this specific value. So we will be able to use the sale money towing option and next under the same set of function on printing to the screen that the system is ready after finishing all the initialization. Let's continue, so I will drill down and go to a the check wave baton. Now, over here, I added a few more A lines off court, the 1st 2 line, actually reading the analog using Dannell agreed function the analog value from the bite. Nous control pain and the speed control pain and plays each one off them into jail viable, so we will be able to use them next. If some bottom related to Dio a wave button was pressed on Lee, then it will print few few things like some text running animation way with the falling Pala Matters. And then I will sprint the spits string and then the speed levels. You see that one function that is called Print will help us to print a spit, but without going into the next line and print. L N is actually printing some value in that's case, the speed level, and then moving to the next life in this sketch I didn't touched yet. The leads meaning I didn't change them speed. I didn't change the brightness We would like only to check the value off the analog sense. So in our case, the potential matter to understand the change that we are getting. And according to that toe, adjust and use, that is an output to something. But this is an important step toe. Help us understand what the sensor is actually generating. Okay, now let's move into the program itself. We will run it and see the result in the single money towing I a window. 54. Project Review: Step-2A: Okay, So, looking on their how'd will that we have for this face? If you remember in step number one, we used to dig ital a switch that are controlling the led that we see over here. The 1st 1 is being used to a test. The old leads every click will tend that on and off. And the 2nd 1 is another digital input switch to Ron a wave that is going up and down every time I'm clicking on that button. And now, as you see, I added two additional sense als simple, sensible that the call put into matter. That's a viable DeSisto, meaning you can go with your hand and change the resistance off that Putin's you matter. And because each Putin's you matter is actually connected with the DRI a connector I just put below the bird board. And that's the while over real Okay, running to the bread board. Now the connection that we have is a to the two sides off ground and power in the middle one. This one is going into the Arduino analog input pins In that case, a zero and the next one a one for the second. Putin's humidor. And because of that, every time that I will play with the potential matter, I will get different resistance and, of course, different level off a voltage that they are doing a will see in the input that pig that's the already. And based on that value, you can do something. In our case, you would like to play with the brightness and speed off the led. However, in these steps, it step to a. We would like on Lee to change something in them, put into matter and see the result in a, well, a sale, money towing screen in our computer. And that is what we are going to do. And of course, the first thing is to go and upload the sketch. So where we go into the jury? No, I d. Click on upload the sketch that we saw you say that the led that Alex and takes already are blinking very quickly and it's ready. It's, ah, loaded into the boat. Now we can see and play with the result. So the first thing I would like to do is tow. Start testing their range off the what the potency matter is actually providing So I will write eight each put into matter to completely to one side in that case, to the left side and on the wave animation button. And if you remember in that function, I'm actually printing something into the screen into the serial monitor screen. And I'm looking right now and I see that I'm getting Speed zero and brightness. That's the minimum value that dependent to matter provide the US if I will go again and then that's a little bit to the right. And this 1 may be a little bit more and run and that again, and I will get some value, some value to the spit. It's a value for the brightness, and if I will rotate it completely, toe the maximum toe, the right side, each one of them. Okay, And run that again. Okay, that's what we are going to see in the is a result that I'm getting the maximum expected value. 1000 and 33 55. Writing Analog Output: dick. It'll signal is to state zero volts five World for any other voltage reference. And it's part off Step one. We already so the dig ital pains support, input and output. In addition, it's part off this step. Step a two part a reality used unal opinions as input. Now what if we would like toa output voltage other than zero vote or five vote, meaning any value between them. Like, for example, 2.8 world? Well, we can't do it directly, you know, doing, you know, unless we will use some external digital to analog converter, something that is called Duck. So how will be able to adjust the brightness off the led? If we have just zero leveled off, I vote that will be like, on and off. I'm very optimistic guy, So don't worry. The good news is that we can get very close to generating analog output value by using a method that is called P W. M. Pulls wide modulation while using a function a court on a local. Right now let's start with understanding what is P. W N 56. A little bit magic with PWM: in the previous step. We just tend they led on and off rapidly. Using digital right function, It seems that we can define the level off brightness, often led by adjusting the amount of time between each lead own. Enough states using pulls wide modulation P W M P W M. Can be used to grade illusion often led being on a different level off brightness by turning the lead own and off very rapidly, it around a 500 cycles per second. The brightness we perceive in our eyes is actually determined by the amount of time the digital output pain is own versus the amount of time it is off. This is also called duty cycle, because our eyes can't see flickers faster than a 50 cycles per second. So the lad appears to ever constant brightness. This method is also used for driving this Emoto. Something will see in next course at viable speed by switching the motor on and off very quickly. So the logic is simple. The greater the duty cycle and meaning the longer the pain is own, compared toe off. In each I cycle, the greater the perceived brightness off the led connected to the digital output pain as we mentioned before, Only specific Dig ital pains support pw em and they are marked on the Arduino board with a tilde a mark beside the number. And that's the reason I decided at the first place to use specific P numbers for connecting our led. So I will be able to use the PW um options in this step. Now the next question will be how we're using the Pwr method in our poor guy. In the sketch. A duty cycle is the percentage off one period in which a signal is on active. We can provide the percentage off a duty cycle as input. Param Eter toe a function called analog right? The function on a rug right will allow us toe access the post wide modulation hardwell on the albarino microcontroller. Now the basic syntax for this function is with to permit the first Param Eter is the key number which can only include one off the pains which support PW M and the second perimeter is the duty cycle expressed in a eight beat into Joe number ranging between the value off zero and 255 the value zero correspond it to off 0% duty cycle in 255 is basically full own or 100% duty cycle. Any value in between these two endpoint provide a corresponding duty cycle A that will approximate and Anna look. Output. 60% duty cycle means the signal is own 60% of the time, but off 40% of the time. In our case, we will use the PW M. It's part of the analog right function toe. Emulate the needed led brightness. 57. Setting the LEDs Brightness: we elderly so that one challenge that we face when using a value form an analog input and sending it to an analog output is that the Anil agreed function in our case will heat in a value in the range off zero to 1000 and 33 while analog right function a walk wheat value in the range off 0 to 255 as they input for the duty cycle. To fix this, we will use again. The Met function with the Parliament er's 0 to 1033 as original range and 0 to 255 is the new needed range. That's all. Let's see that in action, meaning the new updated sketch that is called step to Be and the actual result using the hardware. 58. Sketching in Code: Step-2B: So in this step step to be, we would like to take a the value that we got from the potency matter, the speed and the brightness level, and not just to print it in in the sale monitor. We would like to apply that in our project to actually play and set the led according to that selection. So I added a few new lines in the courts or will school down to the relevant function that is called check wave button. That was the original to line that was responsible for getting the put into metal value. Using Donal agreed a function and I added two additional lines that are utilizing the MEP, a function that help us to MEP the original lead level toe the need of rage. So in that case, that was the original arrange that is coming from DOWNAL agreed. And that's the target range. The same goes to the brightness okay, just different range because we're going to use the brightness level as input today, analog right function that will help us toe emulate the brightness with pulls wide modulation, and that's the input that we need to provide. So after mapping those to a value, then we can use that. So if I will school down again and looking on that court, you will say that I put the digital right is a comment. So it's not being used any more. And replace that with a new code that is gold analog, right, providing again the same free number if from day. With the relevant index and the brightness level as a parliament of and and the next line delay is now using not constant value. But the speed level is an input parameter. And then I'm switching. That am off using the digital right. I could also use the analog right while providing a zero as a duty cycle over and that just the other side again, I'm using Donald, right? The delay with with the new power metal and then switch that off Very simple off the wall. And now let's see the results in our project 59. Project Review: Step-2B: we added a new a line of code that will help us to actually change the speed and led brightness and let actually test that in the project itself. So the first button is of course, testing on enough. No change in that behaviour. However, this the 2nd 1 this one will Iran animation with Okay, that's you see that it's running pretty fast. So if you remember, that's the speed. I am a potency matter. Let's change it. Okay, So I will change that a little bit to the left and I'm expecting much slow Will animation. We've now the 2nd 1 the second put in sumit is being used for a led brightness. Now it is said almost to zero. So if I will attend that a up to the maximum toe the right and then press this button again Okay, You see that the them the lead are displaying in much stone girl light. I hope that you can see that in the video. Maybe I will turn that back and play that again. Now it is much a demon from the last one. So that's all we have. The two Senso on a look sense of the to put into matter once for speed one for brightness. And we learned how to use that in our sketch toe map. The Hell Event range. That's that is super important when we're walking with Senso. And, of course, to use a metal that it's called pulls wide modulation toe. Be ableto emulate an analog output because we don't have on a look out put pain in our day . 60. Step 3 - Motion Detector: in Step one, we handle digital input and output. In Steptoe, we lend about analogue input and how to simulate on a look out. Put in this section Step three. We will learn to use a P IR sensor that is used to detect motion the PS, and so is a nice example off external model or breakout boat that is used to extend the window capability. We will learn how to connect it toe a project. How to read a data sheet related to that model, just the needed special and off course to write the 11 court in our sketch so we'd be able to use it. 61. Step 3 - Project Building Blocks: back to the project building blocks the next and final building block. We would like toe ed toe. Our project is emotion, Detective. The idea is that we will use it to detect some nearby motion movement and triggers event. In our case, the external output in a project are the six led, so we will use them to visual a such event. Connecting the sensor is very simple, however, the court behind it is a little bit more complicated. 62. The PIR Motion Detector: in physics. Motion is a change in position, often object with respect to time, and it's reference point. A sense O is a convertible that measure physical quantity and converted into signal. Now there are two type off motion sensor active sensor and passive sense. All active Senso emit signal, typically light or sound wave, which is reflected back by the surrounding and then the reflected signal is received by the sensor and being measured on the other and a passive sense. So is a device that do not emit a signal, but instead detect in response to some type off input from the physical environment. And we will say that pl Senso is actually a passive sense. All passive infrared sensor all in short, PS, and so is an electronic device that measure infrared light radiation from object in its field of view. Usually it is around 110 degree motion is detected when an in for in for its source with one temperature, such as human body passing from off another infrared source with another temperature. That means when a human or animal body will get in the range office off the sensor, it will detect the movement because the human or animal body emit hit energy, inform off infrared radiation and usually between three metres and seven metal a based on the border that you're using right now. Now the term passive, as we saw mean, means that the period device do not emit an in forward light but passively accept incoming infrared radiation from the environment. Now, for many basic project or product, we may need to detect when a person has left toe entered area off his approach and PR sense of all. Great as they can detect whether human is moved in out off the sense of range and also eight war to mention that it's a very low cost model. The model has just three paints a ground and envy sissy power for powering the model and an output being which provide high logic level if a no object is detected. Also, it has to a potency matter one for adjusting the sensitivity off the sensor and meaning the distance that would like to measure and the other is for adjusting the time the output signal stay high. When an object is detected, you will probably need to check the specific range for the model you're using right now for sensitivity adjustment clockwise, meaning the right will decrease sensitivity and counter clockwise moving left will increase sensitivity. The same goes with time delay adjustment. We can decide how long the output off the PR sent so model will remain high after detecting emotion. Ranges usually between three second and five minutes. Clockwise increase delay counterclockwise decrease delay. The last thing we need to know about it is that the pl sent so required a warmup time in order to function properly. This is due to the setting time involved in learning its involvement. It is recommended to add a delay time in the set up function when the model is operating in case of promotion being detected, the sensor will output high, signal it for a period of time based on the manual adjustment. A. We used using the time delay a potential matter. Now we'll see how exactly were using the sensors in our circuit. How, exactly we're creating the sketch needed to operate that sensor 63. Step 3 - Circuit Design: looking on the circuit design I ended is the P I. R. A model that you see here on the left side and the connection is pretty simple. The three connector on the P A. R s. So the 1st 1 is connected to the ground and the other side is connected to the power and the middle one is connected using the bird board to dig ital pain a 12 Okay, that we will use to read the value form the P I. R sensor. Very simple. And that's the final bottle that we're going to use in this project. 64. Sketching in Code: Step-3: Okay, so we are in step three here. We added our motion detector, the PR send. So now we would like to see what kind off new a line off code we headed into the sketch. So the 1st 1 is a new, global, viable declaration that will help us to know where the PL sensor is connected. Connected Toe bean 12th in our case and a new valuable that is gold pl state that will help us to update the PR sensor state all the time. We'll see how we are going to use that in the sketch itself. Now I will scroll down looking on the set up function. You will see that I added some delay that will help that the p a l send so it to learn the environment. Okay, they when you're turning up the system with the pl sense, so you need to let the sensor to learn the environment. You just need to apply some delay time. I only play without a little bit. So I know that in that case, a 12th is enough. And when it's finished a looking on the sale monitor screen, you see that the system and ready. And of course, it will be able to detect emotion. Now I will scroll down a down to the loop function. I just added a new function that is good check pl and now we'll see that new function check PR will go down. That's the new function. The logic is simple. So we are leading a using the ticket alerted function the status off the pier PR sensor in case it's equal to high a meaning the pl Senso since some motion and it will raise a the signal level. And in that case we will 1st 10 on all the led and we will check the Pierre ST A value because when the sensor is detecting some motion, it will keep them signal high for some period. Okay, something that you can adjust manually using a potency matter on the PR model and decide how long the signal will be high. Now, doing this a time you don't want to switch the lead on an awful the time. So this is why we're using the pl state. And if that's the first time that emotion is detected meaning the previous off the pair state is equal to low. Then I'm pretending to the screen Motion detected and changed that toe high. If I was school down, aim to the under the else options then they of course, when the digital am raid is returning low, Then the that case I will tell off all the led. And if the Pierre state was high, meaning going down from high to low, meaning the motion is they ended And we will a print that in the screen and change the pl state back to low, that's all. That's the cold that we need to use while using MPL sensor. Another thing I would like to show you is the sale monitor skin. So if I will run that okay, let the upload this sketching today both. And now I'm getting some message that helped me to let know that. And this is the music realizing and I'm getting the message. System is ready now we're for we passed my hand near the pay our sense. So I will get the message most motion detected and after some period will get motion ended . I will do that again. Motion detected a motion ended. Very simple. Now we will see that I am on top of the board itself. 65. Project Review: Step-3: looking on the project. Our final project in Step a number three A. I added a new mobile, a sensible that is called Apia. It's being used to detect motion and you can see it's connected with three. A wiles to off them are going into them power and ground. And the middle one is the signal that the p A will provide in case emotion is being detected and it's going into one off the digital. A pain in the debris? No. So we'll be able to read that if I will tend them p i r for a second. So if we look on that, you will see a two potency aumentar that we can change. Okay. And one of them is being used to a adjust the sensitivity, the distance and the other one is being used to set up at the time that the signal will be up in case emotion is being detected. Okay, so this is also something that you can play in a just OK, put that in our case to minimum, it will be like a few seconds that we will see the led that are going to be own for a very short time. Okay, so what? I will do a will Tim deceased them up. Okay, we will wait. Under the system, we finish, initialization will open the serial monitor just to see that is a message that the system is ready. As you remember, we need to put some delay time in the set up function to let the pl sensor toe learned the system. Okay, you say, because I'm close toe the sense, So it's actually detecting my movement. If I will pass my hand, of course, it will turn own. As you see, it's being being 10 on for something like three second, maybe less. I mean, this is something that we can change. We can go into the PR put intimate and play with that in and just that according toe to our needs. Okay, that's all. Okay. These our final project. And this is an example off an external model that we're going to use in all kind of project that we can build without we know system. So if I will summarize first, we learned it. Toe connect. To push baton is a sense of digital sense. So Okay, the 1st 1 is a test baton. Okay, that will turn the lead on and off. The 2nd 1 is running a wave Animation, an animation wave and the two potency tomato are We're gonna look Senso. One off them is for adjusting speed. And the other one is before Justin the brightness off the led and the last one, The last piece off our off. The puzzle is off course and the p a mogul that provides a way to detect emotion. 66. Course Summary: Okay, We almost on the finish line. Thanks for watching. So far. This cause is aiming to provide you the fundamental knowledge around are doing no eco system so you can jump and start building your own project. Let's in high level the flow of topics with a short summary carriage one and also what I would like to recommend as the next step moving forward on your personal learning killed. 67. What did we covered so far?: What did we covered in discourse? So the first thing we have done is exploring. They're doing a platform what kindof application we can use using the Arduino. And of course, as I said, it's only limited by our imagination, and you will be able to find many people worldwide advocating amazing project without. We know. Next we zoom into the you know, you know, bored. And we saw that Also other are breanna both that we can maybe useful at the application and also a the hard way. No, I d. Being used to create the program that we are uploading into the Arduino boat in the next section. We drill down about the syntax in doing a programming. What is a sketch? What is the structure off a sketch? How can we declare a viable using the set up in blue function? And, of course, the syntax itself. How to create loops if an else condition outward comments into the sketch and so on the next section we're dedicated to learn by doing, and we divided our project toe three steps in step number one, and we learned how to. While led component that is very common in circuit. How to use a Resistol to limit the current in a circuit with the lead design. I will sick it with us with the tool that is called fretting how to read digital input. Using that we know and, of course, use pull up and pull down, resist. So how to handle the problem off switch bouncing And, of course, creating the sketch with a albarino i. D application. In Step two, we entered the Anna look side by using a simple, sensible as a viable resist or the potency of matter. And we learned how to read such analog input and how to utilize the sale moon. It'll capability test and see the result that we're getting form on a look sensible, and based on that input we can use at the map function, Toe met the range according to our needs. And next was to use the value that we are reading from such an honor looks and so and then writing that is an analog output, and we saw that there are no analog a output pins in the bueno. So for that we're utilizing the poorest wide modulation, a method that are supported when on some digital pains in the Arduino and using all of that , we set the led speed in brightness, using the to Putin's humidor in step number three, the last one, we added a P I a sensible as emotion detection. Now the idea is to show how we can extend the capability off the albarino by using an external model. And such model can be also adjusted using physical parliament. And we saw the to Putin's you matter that we have on top of the model, that we can adjust the sensitivity off the model and the delay time. And of course, we need to a actually open the model that I should be able to see the exact parlamento on the component that we're using in our project and, of course, using the data that we're getting from the sensor. So we learned how to read the sense of digital output as event so event can be up and down and the system should behave according to the relevant event like motion detection or motion ended 68. What Next ? Level 2!: as I mentioned the Casey about Arduino is plan Toby, A collection off few courses, divided toe levels, level number 123 and four enabling a student toe. Understand? And I just the possibility without do we know in a step by step, this is level one, meaning the first course in the Pogba, and I will release new levels going forward. Anyway, I will also let you know as soon as a new course will be a list I will be more than happy to. Well, if this course helped, U. S O feedback will be more than welcome. Thanks again for watching and good luck in your next journey.