Our senses take our environment in and capture its nuances as signals our brains can interpret. We can feel variations in heat and see changes in lighting, these signals allow us to respond do our environment appropriately.Analog sensors to the same thing for electronics, translating physical environmental data to electrical signals.They send a range of values proportional to the amount of voltage accessible. In the illustrated instances, they send a value between 0 and 5v. Different micro controllers can interpret different ranges of signals; for instance, the Arduino translates this signal to a number between 0 and 1024 that we can map for other uses in our code, as in this example using a servo motor.
Since they always return the same range, swapping out one analog sensor for another is simple. More sensitive sensors, like photocells(which interpret light singals), need a resistor to limit their range and minimise shaky or unstable readings. They also need lots of light to get their whole range, and can be paired with ‘blinders’ to concentrate how they’re affected. Potentiometers get their range by using a resistive element and a wiper to connect it at different points along it. The closer the wiper is to the beginning of the resistor, the smaller the amount of resistance and the higher the electrical signal being passed through. Like this, you can map the rotation of the wiper quite precisely.
Arduino Reference for Analog Input
Digital Inputs are binary signals. Off/On, 5v or 0. They do not have any range, either they are conducting or not. Tilt sensors work this way, featuring two small metallic balls that bridge a gap in the internal circuit when upright, allowing current to pass in this state. When they are tilted horizontally the balls roll away, cutting off the connection. Because the balls are light and can shake, it’s important to use debouncing code, code that makes sure the connection is well established by double checking it twice in a moment.