In this chapter, we learned how to work with analog inputs to measure voltage values. We understood the impact of the different bits of resolution for the analog to digital converter and we wrote code that converted the raw units read into voltage values.
We measure voltages with an analog pin and both the mraa and the wiring-x86 library. We were able to transform a variable resistor into a voltage source and make it possible to measure the darkness level with an analog input, a photoresistor and a voltage divider.
As in the previous chapters, we continued taking advantage of Python's object-oriented features and created classes to encapsulate voltage inputs, darkness sensors, and the necessary configurations with the mraa and wiring-x86 libraries. Our code is easy to read and understand and we can easily switch the underlying low-level library.
We fired actions when the environment light changed and we were able to work with both analog inputs and analog outputs. Finally, we registered...