It’s not really programming, but the difference between analog and digital are really important to understand if you want to work with robotics in the future. Here’s what we’ll be covering on this page:
Sensors that Make SignalsThere are many sensors that measure things in the world or control electricity. On Sparki there are a bunch- infrared sensors, an ultra-sonic sensor, a compass, an accelerometer, a switch (on/off) and a button. The sensors are called “inputs” because they put electricity into the robot in some way or another. The way they put electricity into the robot is what makes them either digital or analog.
Digital SignalsDigital sensors can only be on or off, there is no in between. When a digital sensor is on it sends all the electricity from the circuit into the robot. When a digital sensor is off it will not send any electricity to the robot. When reading a digital sensor the robot compares the electricity coming from the sensor to a HIGH electrical signal, which is all of the electricity that the robot can stand. The robot also compares the electricity to a LOW electrical signal, which is usually a connection to the ground of the robot’s battery. When there is all the electricity present the robot calls this signal a HIGH signal, it is also sometimes referred to as a TRUE signal or with the number one. Digital signals are like boolean variables (because they are boolean) and so all the things we used to think about booleans can be used to talk about digital signals- a coin with two sides, a light switch, day and night. You can think of a robot using a digital signal as plugging and unplugging an electrical cord in an outlet. Either the cord is in the outlet and there is electricity or the cord is not in the outlet and there is no electricity. It’s not possible to have an electrical cord that is sort of plugged in. There aren’t a lot of digital sensors- mainly there are buttons and switches but you can think of the communication between the chip based parts of the robot as digital. Technically the Bluetooth communication that Sparki uses is a bunch of digital signals. Here are a couple examples of digital states that a robot might measure- whether there is a wall in front of it or not, whether there is a line below the robot or not and whether its reset button has been pressed or not. What are some other examples of digital values that a robot might measure? (This is harder to figure out than you might think.) Robots will also use a digital signal to control outputs like motors and LEDs. Robots that use a digital signal to control an output like that can only turn the output all the way on or all the way off. That means they can blink an LED, but they can’t make it turn on just a little bit. (There’s a way around that called Pulse Width Modulation.)
Analog SignalsMost robots will have at least one analog sensor. Analog sensors can measure in ways that digital sensors can’t. They can measure a little bit of light, a brighter light or the brightest light ever! That’s really useful since most of our world isn’t measurable in true or false values.
There are a bunch of different ways you can think about this- one is like figuring out how tall you are compared to your classmates. Imagine that you don’t have a tape measurer but you want to tell your teacher how tall you are. So you line up all the kids in your class from shortest to tallest. Then you can walk down the line comparing yourself to the other kids. If Aimee is taller than you, take a step backwards to the kid just before Aimee. Maybe that’s Michael. Now you can tell your teacher that you are about as tall as Michael and the teacher will know how tall you are in comparison to all the other kids in the class.The number of kids in your class is similar to the analog resolution of a robot. That’s how closely a robot can measure an analog value. Analog resolution can be different depending on which robot you are using. SparkiDuino divides its analog sensor values into 1023 values. That’s means it can measure 1023 different shades of brightness from a light (or an infrared light) and 1023 different distances with its ultra-sonic sensor. Pretty good, huh?