This sets x
to a value from -15 to 15 (inclusive) based on the voltage at pin analogPort
. 15 means 5 volts and -15 means 0 volts.
This value is then used to set a delay between 100 (-(pow(2*15,2))+1000) and 1000 (-(pow(2*0,2))+1000) since the square of 2*x
and 2*-x
yield the same number.
In other words, 0 volts will cause a 0.1 second delay, 2.5 volts will cause a 1 second delay, and 5 volts will cause a 0.1 second delay.
The map
function maps one numeric range to another. One could convert from Celsius to Fahrenheit with map(temp, 0, 100, 32, 212)
.
The analogRead()
function returns a value from 0 to 1023, so it is mapped to the more useful range of -15 to 15.
4
solved What is the outcome of this function? [closed]