Luvun sisältö

Edellisessä luvussa käytettiin kytkimiä, joilla on vain kaksi asentoa, päällä ja pois, ja sama päti myös luvussa testattuihin ledeihin - päälle tai pois, muita vaihtoehtoja ei valolle annettu. Napilla ja ledillä oli siis rajattu määrä arvoja - tässä tapauksessa kaksi. Digitaalisilla antureilla ja signaaleilla on aina rajallinen määrä mahdollisia arvoja.

Alla olevissa esimerkeissä ohjataan ääntä ja valoa kytkimien sijaan antureiden välityksellä. Käden hienovaraisetkin liikkeet vaikuttavat ääneen ja valon määrään!

Todellinen maailma on digitaalisen sijaan analoginen. On olemassa ääretön määrä värejä, äänenvoimakkuuksia, kuultavia taajuuksia sekä hajuja. Arduinon sisäinen logiikka on digitaalista, eli se käsittelee rajattua joukkoa lukuarvoja. Suurin osa kytkentälevylle tehdyistä kurssin virtapiireistä taas on analogisia: sähkövirta on jatkuvaa, ja sen kulkuun vaikutetaan erilaisin komponentein. Tässä luvussa tarkastellaan, miten digitaalinen Arduino voi saada tietoa analogisesta maailmasta, ja kuinka sen avulla voi jäljitellä portaattomasti muuttuvaa analogista signaalia esimerkiksi ledin himmentämistä varten.

Voit katsoa alla olevan videon johdantona kurssin neljänteen lukuun!

Addohms: Difference between Analog and Digital | AddOhms #6

Tekstitykset

almost every day we hear about things being described as analog or as digital it's kind of like the difference between men and women no wait this is the wrong channel for that instead it's like old cell phones which used to be analog but now they're all digital at this point most countries have either changed or in the process of changing their television transmissions from analog to digital as well ah heck even clocks can be analog or digital let's use these clocks to learn the difference between analog and digital electronic signals you even though there are only 12 numbers on the face of this clock you can always tell how many minutes have elapsed just by looking at how far the minute hand is between the two numbers when we look at a digital clock all it can do is show us for each digit of the time the numbers 0 through 9 even if we zoom in really really close we can't see how close the clock is to flipping to the next digit so this means the increments of time are fixed to certain digits or levels okay okay okay I know you're asking me how does this all apply to electronics let's use this to talk about analog electronics first so we got to go back to the analog clock as the clocks hands sweep across its face the time displayed is continuously updated with nearly infinite precision the key here is the continuous change analog signals are signals that are continuously variable or in other words continuously changing just like the time on the clock as we learned in the video on the difference between AC and DC the AC voltage in your house continuously changes at a rate of 50 to 60 Hertz imagine that we had the ability to stop time and look at the voltage okay I know bad pun but what I wanted to show here is that as we move across in time that the voltage value is constantly changing this doesn't mean that analog is only found in the wall sockets or through AC it's just a very good example in fact there are sensors like this accelerometer which provides an analog output this sensor varies its output voltage depending on how much acceleration is occurring if you want to use that analog voltage with a digital system like an Arduino then you're going to need to convert that signal to digital first going back to the digital clock remember that time can only be represented by fixed number symbols like 0 through 9 the same thing is true in digital electronics the digital signals can only be represented with fixed symbols like 0 & 1 but how do you get those zeros and ones well it turns out that they're formed from voltage digital signals can have both a high level and a low level and so what this means is that at 0 volts these signals considered a digital 0 and then at some high voltage say like five volts the signal is considered a digital one as it turns out digital isn't quite this absolute depending on the transistor technology being used there is a range that the signal might be considered a zero or one for example on this Arduino Uno a digital zero is considered zero volts up to 0.5 volts while a digital one is anywhere from 3.5 volts up to 5 volts and so there's these two bands where there's the low and the high the area between the low and the high is an undefined area a digital signal with a voltage in this zone could either be considered a 0 or a 1 because digital logic needs to have a value associated with it this undefined region will get turned into ones or zeros problem is we can't always predict which one that they will be the key to understanding the difference between analog and digital is to remember that analog voltages continuously change while digital voltages have defined levels when you step back and think about it it kind of turns out that digital signals are actually analog signals where the voltage levels have special meanings you