Increasing Precision Using a Temperature Sensor
Support for floating-point numbers is an improvement, but it mainly increases the precision of our program’s output. We could’ve achieved a similar effect using some integer math tricks. But now we’ll add an even better improvement that cannot be imitated using software: a temperature sensor.
When I told you that sound travels through air at 343 m/s, I wasn’t totally accurate, because the speed of sound isn’t constant—among other things, it depends on the air’s temperature. If you don’t take temperature into account, the error can grow up to a quite significant 12 percent. We calculate the actual speed of sound C with a simple formula:
C = 331.5 + (0.6 * t)
To use it, we only have to determine ...
Get Arduino: A Quick-Start Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.