Placeholder Image

Subtitles section Play video

  • Hello, world.

  • This is CS 50 today.

  • We're not gonna be talking too much about software today.

  • We're gonna be working with hardware.

  • In fact, my particulary favorite type of hardware are doing those good afternoon.

  • My name is Robert Joe Marmalade.

  • This is CS 50 and today we're gonna be going pro with are doing no.

  • So you might be asking, what is our doing?

  • Oh, well, physically I have it here in my hand Or do we know is this microprocessor microcontroller where essentially you can put a bunch of electronic components together and control them together?

  • It's open source.

  • So the hardware and the software is available for anyone to use.

  • That's why there's a lot of knockoffs available, but these knockoffs have the same exact quality as this are doing aboard, so it doesn't really matter which type which one you get.

  • But in the end, the greatest thing about our do we know is that it's great for making electronics projects.

  • So, for instance, here someone is making some remote control circuit or another person made this remote control robot with a bunch of servos and ultrasonic sensor.

  • All of these is possible with our doing?

  • Oh, so you wouldn't be wondering.

  • Ok, what are we gonna cover today?

  • Well, Arduino is quite a large topic to cover.

  • So appearing aboard what is going green owes order gonna cover and red is not what we're gonna cover.

  • So first, what we're not gonna cover unfortunately are doing to involve some electrical engineering.

  • As you can see here, with these bread boards, you have to make sure things are wired properly.

  • We'll teach you the basic electrical engineering, but if you want to know more advanced than I would highly recommend checking out books are asking or taking out online for more.

  • Resource is next is working type of different types of are doing a boards most are doing awards are about the same.

  • But the thing is, for now, we'll just be working with the Arduino, you know, because this is pretty much the standard board that people use and finally, its aggression or external hardware.

  • It is possible, for instance, one time they made a robot arm that could be controlled through python with voice commands.

  • But the thing is, that involves a little bit more technicality, and this is kind of outside the scope of what we want to cover today.

  • So unfortunately, won't be integrating hardware with or do we know with any other thing just with the laptop to send in the new code that are doing a well run?

  • But what we are gonna cover is one setting up because we got to start somewhere.

  • And of course, we've got to start with setting up.

  • And the next thing is we also need to work with basic are doing, oh, components so strong.

  • Here across the table is various components I have here is an led circuit.

  • We also have a button.

  • Here we have this ultrasonic sensor which is used for measuring distances.

  • We have this serval which can be used for many, many things, such as creating movement, moving objects.

  • Here we have this potential ometer, and these components will essentially form the basis of what today's seminar is going to be about.

  • Now there's some extra components here.

  • Such asses.

  • This nine volt battery is voltage regulator.

  • But Indian, what really matters is these core components and what we're gonna learn because Indian we want to make sure that through working with the simple projects and going to the bug in common issues.

  • We want you to have the foundation toe work on cool or doing a project so you guys can start to dream about what cool projects you want.

  • Attack along next.

  • Okay, so first, this is gonna be the agenda for today, and we'll start.

  • And here is also the materials so are doing.

  • It does involve some materials you have to get because it is a hardware project and hardware is not as cheaper software, but it is highly rewarding.

  • And if you want to follow with today's seminar and topics, these art of materials you will need so strong here across the table, we have this or do we know?

  • You know, we have a lot of wires, and as you can see with these bread boards, there's a lot of wiring involved.

  • We have several bread boards, but you just need one.

  • And then we have this cable to transfer the code from our laptop to the R.

  • Do we know?

  • Then we haven't led a button.

  • Several types of resistors, a potential ometer ultrasonic sensor and a serval first getting settled.

  • So are doing oh, can't be run on the CS 50 e because the CS 50 i d doesn't have it.

  • However, I would highly recommend downloading and installing the Arduino into your computer because this is the best way you can work with the hardware, and also you can work off line.

  • However, if you are inclined to work on the Internet are doing Oh, does have a Web based editor, which is a cloud version.

  • You can follow the link there posted onto the screen, and you can see the cloud software they have available to work with are doing a code.

  • Assuming that you get set up, let's start with the I D.

  • So here's a picture of the I d e.

  • But better let's actually go to the real I d.

  • So as you can see here, this is our Do we?

  • No, I d We're gonna put all our code here.

  • It's gonna run between these things, and we're gonna have several several things in here.

  • But the important thing is, we want to focus on several key things.

  • First, is this void set up?

  • So what void set up means is that when the board is running for the first time or whenever you press the reset button on the board.

  • This is the batch of cold that's going to rerun.

  • So, for instance, here is going to set this pin to an output pin every time this has been set up.

  • The next major part of the code is loop.

  • So are doing no is a micro controller, and the purpose of one of the huge advantages of our doing Oh, is that as long as it has power, it can continuously run the code until you press reset.

  • But once you press reset, it just runs a set up again.

  • And then you go back to the loop.

  • And what Luke does is it kind of runs like a wild, true or a forever for Luke.

  • And it just keeps running and running to cold.

  • Whatever is there.

  • So as long as they are doing oh, has battery or power running through it, it'll keep running that batch of code within the braces off the void loop.

  • Now, the next thing is, we also wanna be familiar with some of the things we have to set up.

  • So over here, if you check out the tools tab, you can check out the different types of boards available.

  • Comma, Another common bug that people face is dealing with is sometimes choosing the wrong board.

  • So to simplify today's lecture, we're just gonna use the Arduino snowboard and also this port number.

  • Now it's not highlighted because are doing is not connected.

  • But allow me to connect this to the Peter and Port basically is in charge of making sure that all the commands get scented a specific port.

  • So you can see over here that it's on com five and And, of course you want to save it just to make sure you receive all their spaces back.

  • Okay, now we finish the set up and we kind of see howto are doing No, I d looks like.

  • Now let's get on with basic electrical engineering Now, this is a huge simplification of the whole electrical engineering field, but this is what I found helpful.

  • That helps me understand and at least get my foot off the ground working with hard work projects.

  • And these are the five rules I generally follow.

  • The Rule one.

  • Electricity flows from positive to negative to ground so we can see here with this simple circuit that electricity flows from the positive flows from the positive wire down the negative wire and from the negative wired goes to the ground so you can imagine it as a waterfall analogy where we have our water source a top water or a K A.

  • Electricity is flowing through a circuit until he reaches the lowest point point, a k eight ground and all components in this circuit have to obey this law.

  • So make sure that you always make sure that your components have this positive connection are connected to this negative terminal and floated ground.

  • So remember positive to negative to ground Second must float to the same ground, so we're going to see that soon.

  • See here with this serval components that things are not going to get a little bit messier.

  • But the thing is, we all want to make sure we share the same ground.

  • And for the sake of today's seven are the same ground will be.

  • This are doing aboard.

  • The ground is basically we're just electricity flows because, as we saw from Rule One, it flows from positive to negative to ground.

  • All electricity has to flow to the same ground or the same point.

  • And as I've said before, nor do we know is going to be that ground.

  • Now, the next one.

  • Same wire, same rail, same flow.

  • Okay, so we all know that electricity conducts and it follows.

  • For instance, if I stick a metal wire into the outlet, obviously there's gonna be electric flow flowing there and from these wires, What I mean by same wire, same rail, same flow is that the same quote unquote electric signal is going to be flowing between these wires.

  • So if this comes from pin nine of our doing Oh, the electrics to go from pin nine is gonna flow from this wire now.

  • What do you mean by seem real?

  • Since we're dealing with bread boards, we're gonna need to make sure we understand how things work with bread boards.

  • So the bread words on this table follow this schematic and imagine each of these green lines as one rail.

  • So this entire column means that if I stick, let's say a signal from pin nine there, this whole rail will contain the signal from pin nine, because electricity, as we've seen from here, flows from positive to negative the ground.

  • It's gonna flow from here.

  • And then it's just going to sit there until it continues flowing.

  • Now, also on top.

  • It's kind of the exception here is just these air continuous lines.

  • So this means that if I plug something into here, that electric signal is gonna flow through his entire rail here.

  • And same for the red one down there now for today's convention, Blue will just mean ground and red will mean the positive voltage.

  • You can do it whatever way you want.

  • There's no rules against it.

  • It's just that to make things simpler, Fire simplified and dork with kind of convention was just be sticking with blue as ground and read as vice voltage.

  • Rule number four don't exceed the voltage.

  • Okay, So thing is, we can break electronic components pretty easily just by sticking these things.

  • So, for instance, we have this led right over here.

  • This small little beauty unfortunate can only take about to volts.

  • If I was to stick it directly to this nine volt battery, this thing's going to heat up and blow up, and it's also gonna die.

  • And I might get some burns, which we don't want any of those things that happen because these are precious components and we don't want to hurt your fingers.

  • So to make sure with that we want to make sure that the voltage is controlled and we do this either to resistors or separating the type of voltage that flows.

  • So for this, you might be wondering, OK, why is this the case?

  • Well, final rule for today is alms Law vehicles, I R.

  • So we're not gonna be doing any calculations.

  • All of these have been done already for you with the calculations, but essentially it relates voltage.

  • It means that voltage equals the resistance times, the current times, the current.

  • And if you do the math, you can see why some time why you can see why some components will blow up.

  • Or sometimes some components won't run at all.

  • Okay, so next we're going to start off with ladies.

  • So as we've seen here, this is an led.

  • It has is basically just a fancy.

  • Just look.

  • It's just essentially a light bulb where there's a positive terminal over here and negative terminal.

  • And then here are some various colors, eh, ladies And here are the commands on the screen that are most relevant to how and led will work.

  • So we're gonna have pin mode and digital, right?

  • So in our doing, open mode means setting the pin up for something by default.

  • It sets it to input.

  • However, for led is because we want to output output a light where I have to set.

  • This led to output and digital, right?

  • This is varying.

  • The voltage that's flowing to the led since you are doing is controlling how that electricity flows.

  • We want a very from high to low, Kate.

  • So, as you can see here, we have the circuit set up this small circuit.

  • We have a resistor here.

  • This will protect the led from blowing up because they are doing oh, provides about five volts directly to the led.

  • And if we didn't have this resistor this good, this could severely damage it.

  • It might not look like it in the beginning, but is gonna damage it.

  • So we want to make sure we protect against that from happening.

  • Then also, we have this.

  • Then we're gonna flow from the positive terminal to the negative, and then from the negative is gonna float to the ground A k a.

  • The ground pin on.

  • Nor do we know.

  • Okay, so let's set of these final connections.