Arduino接口-week1-Lesson1

This series of articles are the study notes of "Interfacing with the Arduino", by Prof. Harris, Department of Computer Science, University of California, Irvine. This article is the notes of week 1, lessen 1.

1. Lesson 1

1.1 Lecture 1.1 - Electrical Circuits

1.1.1 Hardware and Software

(1) IoT devices combine hardware and software

So, in a thing's components are designed from hardware and software combined. So you don't just have the software that you write, just have the code, it's always wired to some kind of different hardware components to make something happen in the real world or to receive information from the real world. So a combination of hardware and software, and this is part of what makes them harder to design than traditional systems. So, it's not just a traditional software system like desktop software and all you think about is the code and then you make it run on an arbitrary desktop. In this case, you're writing software but for a specific hardware platform. And a hardware platform that may not be developed yet.

(2) Hardware interacts with the world
So, the hardware is what really interacts with the physical world. It does everything. It receives input from the outside. It actuates, so it does things on the outside world. So maybe is has a microphone that picks up sound. It has a speaker that outputs sounds, something like that. So, it's the hardware that's actually interacting with the outside world.

(3) Sofeware is the “intelligence”
But it's actually the software, usually the software that acts as the intelligence. So the software takes the data received from the hardware, interprets it in some way, and then causes the hardware to do something, orders the hardware to do something. 
So for instance, say you've got some kind of sound going on. The sound and your system's supposed to hear the sound. And if somebody says a word, then it should trigger a behavior. So let's say when somebody says, turn on TV, the TV should turn on. So you'll have a microphone that's receiving the information, receiving the sound, the words, turn on the TV. Then, the software will process that information, realize what the words are, turn on TV. And then it'll say, whenever I see that I want to turn on the TV. So, then, it'll have an actuator. That drives some hardware that actually activates the TV turning it on. So, that's the way I think about it, the software is the intelligence inside, but the hardware is actually doing all the work, so you need both.

1.1.2 Electrical Circuits

So because of that we need to know a little bit about electrical circuits right, we gonna be building some small circuits.  when you're doing this type of IoT design you need to know a little bit. Not much, but a little bit. Most of this, in the class, we are focusing on software. But there is this hardware side and we need to know a little bit.


  • Electrical current flowing through wires
  • Battery/ power supply moves current
  • Water flowing trough pipes
  • Pump moves water

We're going to talk about current going through a circuit. And we're going to compare that to water going through some kind of water pumping system. It's a very similar analogy. It's a common analogy for explaining electronics. So, you see on the left side of the screen, you got electrical current flowing through a wire. So, you got a battery over there. It's got a plus terminal, minus terminal and current flows through that wire that connects the plus terminal to the minus terminal. It goes from the plus to the minus through the wire. 

Now that is similar to a water pump system. And this pump is pumping the water through the circuit. And it's a very similar idea and so that's the analogy that we're going to be talking about for a few slides. And note that in the electrical circuit, the battery is pushing the current, providing the power it needs. In the water system, the water pump is pushing the current through. But they are performing similar functions.

1.2 Lecture 1.2 - Electrical Properties

1.2.1 Voltage

So, let's talk a little bit about basic property properties of electrical circuits. Start with voltage. So, we got our circuit on the right, on the left side it's green rather. And to the circuit in this case has got a battery on the left. On the right, it's got that squiggly line there, it's called a resistor.

And current's flowing from the positive through that resistor to the negative. Now, on the other side over there next to it, we have the water, the analogous water circuit. Now, the water, they've got a pump, it's pushing water, and notice that I put some rocks inside the pipe. So, these rocks are providing resistance to the water flow. So there, I'm gonna call those resistance. Those are similar to the resistance inside the electrical circuit.
  • Voltage (V): Potential difference between two points in the circuit
  • Like pressure in a water system

Think of voltage as the pressure. So, voltage is just like the pressure in the water system. That pump provides pressure on the water that you can measure with, say, a pressure gauge, right? But note that, pressure is what actually pushes the water through. So voltage, that battery in our picture is actually providing some voltage. Providing essentially the pressure on the carriers on the electrons to push them through the circuit.

  • Pressure difference is what counts

So, think of voltage like pressure in pumping system. Now note that, pressure difference is what counts. So, what I mean is. There's pressure but current only flows if there's a difference in voltage. Like in water pumping system.

If they're equal pumps with equal pressure, then there's no current flowing, even though, you've got high pressure on one end, high pressure on the other. The pressure different between the two end points of the pipe, there's no difference in their pressure. So, there's no flaw. So, even though, there's high pressure, the pressure difference is what counts.

That you put that out, what they call potential difference, difference in Potential. So, between the positive and negative terminals of the battery, you have a potential difference of whatever amount of voltage the battery is. So say, that battery is rated at five volts, then that means, there's five volts potential difference between the positive and negative terminals. Which means, that if you wire those two together, current will flow from the positive to the negative.
  • Measured in volts (V)
it's measured in volts. And I should note that the voltage on anything that is connected by a wire, like just a plain wire, positively conductive wire, they have the same voltage, right. There's no resistance in between. Of course, in our circle we have resistance in between. Okay, so that's voltage.

1.2.2 Current

  • Current (I): Rate of carrier flows
Current is what you think of it as, is the rate at which the carrier flows past the point in the circuit. So, if you look at the water, the rate at which water is flowing past the point in the circuit, you call that the current flow or the current rate. And you get the same thing in our electrical circuit.
  • Flows form positive to negative
Now, current flows from positive to negative. That is the standard. That is what people say. Now, that's not exactly what happens. 
  • Electrons flow from negative to positive
So, in current, with electrical current our carriers are actually electrons. And that, well we don't need to know this for the class, but I should throw this in because sometimes it's confusing.
Understand that electrons are negatively charged characters.So, they don't actually flow from positive to negative, they flow from negative to positive. So, even though, we say that current flows from positive to negative, in reality the electrons are flowing from negative to positive.
But still, when people talk about current flow, they always say oh its going from positive to negative so always think of it that way. I just wanted to mention it to you, because sometimes, if you know anything about electrons, then it can be a contradiction in your head. So, that's there, but just understand that everybody says positive to negative current flow. They're talking about the holes, the lack of electrons is moving from positive to negative, you can think about it like that.
  • Measured in amperes or amps (A)
It's measured in amperes or amps. So, one amp is a unit of current.


  • Resistance (R): Any obstacle to current flow
So, resistance is basically and obstacle to current flow. 
  • For water, might be a rock or narrow pipe
So, in terms of our water system, I put some rocks in the pipe and that's a resistor effectively. It's providing resistance. It's slowing the water flow and reducing the rate, right? So, that's resistance. There are lot resistances you can put in there. You could put a sponge in there, right? And that would, you know, water could flow past it. But it would be, it was hard to flow past it. So, for water, just a rock or a narrow pipe. If you make the pipe narrow, that adds resistance, right? It makes, it's harder to push, though pumped to a very narrow pipe, as compared to a big wide pipe. So for water, that could be the case.
  • For circuits, might be a bad conductor or a narrow conductor
For a circuit, it's basically a bad conductor. A sub-optimal conductor. So, if you just have pure copper wire, there's very little resistance in there, and it’s very good for conducting. But, if you use some other material that doesn't conduct as well, then it has a certain level of resistance.
You can different types of materials that have different levels of resistance per unit length. Also a narrow conductor. The narrower the conductor is, the more resistance there is. So, if you take a wire, you have a big fat wire, that's less resistance than if you have a really thin wire. And actually, this is important with high power electronics. You have to use big fat wires because there's so much current the resistance will produce a lot of heat, so you need big wires to drive a lot of current or else you'll get too much resistance. So, that's what resistance is.
  • Measured in Ohms (Ω)

1.3 Lecture 1.3 - Ohm's Law

Ohm’s Law

Let’s just talk about Ohm's Law. So Ohm's Law is the relationship that you see right there. V = I*R, voltage equals current times resistance. This is a useful relationship to keep in mind. It's simple, but we need it for lots of little things. 

(1) expresses the relationship between V, I, and R
It expresses the relationship between voltage, current, resistance, and it tells you a few things about the behavior of circuit. If you increase the resistance then current will go down That makes sense because the voltage is fixed, right. Our Arduino is running at five volts, it's driving five volts under its output pin. So anything you connect to it, if the resistance goes up, I has to go down to keep the relationship the same.
(2) Used to compute 1 value given the other 2
It’s used, so one way to do it, to use this relationship is to compute one variable when you're given the other two. So say you know the voltage, you know the current, you can solve for resistance. Or you can do it the other way. Say I know the current and I know the voltage, or I know the current and I know the resistance, I can solve for voltage, and so on. So given two, you can solve for the other one.
(3) Some common uses:
  • What resistor do I need to limit current flow?
So when would you need to do this? So, one use is what resistor do I need to limit current flow? Now this is going to happen a lot, where your Arduino is connected to a component and this component, it only accepts a certain amount of current.If you give it too much current, it will blow up. Something bad will happen. So you know that when you connect it to this component, you have to add some resistor just to reduce the current flow to the appropriate level.
So, if you want to figure out what resistance do I need to make sure that my current is low enough, you plug in the voltage say, and Arduino is five volts. The current limit that you want, you plug that in. And then, you can solve for the resistance and say okay, this is the type of resistor that I need.
  • What voltage can I expect for a given resistance?
Another one is, what voltage can I expect for a given resistance? And this is more on the, this is commonly something you need to figure out on the input side, so I will get to this in a later module. 
But, the idea is that say that you are doing this connector to some sensor of some kind. And this sensor, so our Arduino, it's gonna be reading the voltage that this senor is outputting. But what voltage do I expect? So, say I have it connected to a light sensor. When the brightness is a certain level, I'll get a certain resistance in my sensor, so what voltage would I expect to see in my Arduino? So I can use this type of equation to figure that out. Well I know what the current has to be and I know the voltage will be this, the resistance will be such and such at this light level, so the voltage has to be. And then you could use that inside your program and say, if the voltage I measure is greater than this threshold, then do this, else do that, and so on. 
So V = I * R is sort of a very common law and you use it a lot for lots of little things.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值