Chapter 2. Working with Sensors
A sensor is a device that can detect changes or events and provide a corresponding output. The output is usually an electronic signal, for example, a light dependent resistor (LDR) outputs a voltage, which depends on the level of light cast on the sensors. When working with electronics, sensors are often divided into analog and digital sensors. Digital sensors can only detect two states, either on or off. The digital sensor can only distinguish if there is voltage going into the sensor or not. In code, this transfers into a 1
for voltage coming in and 0
if there is no voltage present. This is why they are called digital sensors, since they only operate in 0s and 1s. This means that these sensors only have two states, either on or off. A button, for example, is a digital sensor, which can only sense two states, if the button is pushed or not.
Analog sensors, however, can sense a range of values. The LDR, for example, is an analog sensor that changes...