Chapter 6. Analog Inputs to Feel Between All and Nothing

We have come a long way up to this point, learning to deal with digital and analog outputs and also digital inputs. It is now the moment to show you how to manage analog inputs, as they are what enrich the microcontroller field of application the most.

In this chapter, I have prepared two projects to help you understand how to connect, configure, and program analog inputs and what kind of things we can do with them. I'm sure you will be totally amazed once you get the point.

Sensing analog values

In Chapter 4, Controlling Outputs Softly with Analog Outputs, we talked about digital to analog conversion and the use Arduino makes of its internal DAC when generating analog outputs. In this chapter, we need to know about the DAC cousin, the Analog to Digital Converter (ADC).

An ADC is a device with just the opposite mission of a DAC, that is, a device that takes a signal that can theoretically have an infinite number of states and convert it to just a few concrete values, or in Arduino jargon, takes an analog signal and converts it to a digital value.

Just like the DAC, the Arduino board comes with a six-channel ADC with a 10-bit resolution for each channel. This means that we can deal with up to six different analog signals ranging from 0V to 5V that will be converted to values between 0 and 1024.

If you remember from Chapter 4, Controlling Outputs Softly with Analog Outputs, the DAC had just an 8-bit resolution, allowing for values between 0 and 255, so we will have to keep this little difference in mind when working on projects that sense and act in an analog way, and we will have to make some kind of correspondence between the 1024 possible input values and the 255 maximum output values: a usual operation commonly called mapping.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.214.230