The tutorial indicates that the analog to digital converter returns values ranging from 0-1023 from analogue inputs ranging from 0 to 5 volts. Wouldn't the range therefore be 1024, which if used in this line of code would seem to give slightly low values, and never return a value of 5 volts? Or am I misunderstanding the definition of "range."
The authors of the tutorials used float as the data type (I think that's correct terminology) - not sure why that was chosen over int.