Using inputs in robotics projects
You can do a lot with output devices in robotics projects, but the possibilities become endless when you add inputs. Whether they are user-controlled inputs, such as buttons and potentiometers, or environmental sensors that measure things such as ambient light or air quality, input devices can add a new dimension to any robotics project.
Â
Digital versus analog input
Much like with digital and PWM output, there are two types of input devices: digital and analog. Digital inputs are either on or off: buttons are a prime example of this. Analog inputs give a different level of voltage of signal depending on what they are sensing; a photoresistor, for example, puts out higher voltage signals when the ambient light is high, and lower when it is darker.Â
In order to read data from analog devices, you'll need a pin that can accept an analog input. But as we saw in the last chapter, all of the GPIO pins on the Raspberry Pi are digital. Luckily, there are ways to get...