I'm going through the Arduino Projects Book as an introduction to working with these boards, and am on the third project, and am wondering if this line of code is correct:
float voltage = (sensorVal/1024.0) * 5.0;
It's intended to map a range of 0-1023 to a range of 0-5, but wouldn't it give you (very) slightly inaccurately low values, and never return a full 5 volts? Shouldn't it be written as follows:
float voltage = (sensorVal/1023.0) * 5.0;
Am new to programming and electronics and am educating myself, so please forgive me if this is a stupid question. Tried googling this project and question without results, wasn't sure what kind of general search to enter, and searches involving general "off by one" and "voltage mapping" queries drowned me in irrelevant answers.