|
Re: Simple problem with variables
Initializing a variable is something you normally do with a predetermined value at powerup - like setting it to zero, or 127, or 255
I dont think that going out and reading an input register would technically be considered initializing it - because to get that analog input register value, the code has to be running
maybe you are confused a little between initializing it (at powerup) and reading the input for the first time when your code runs?
If you want to read the initial value of the pressure sensor when the robot is first turned on, you should have a separate variable for that, and some way to make sure you only read the sensor input once after the code first turns on.
for example, initialize the variable to a value that it could not possible get from the sensor at power on, like maybe 254
then somewhere in your code have something like
if initial_pressure = 254 then initial_presssure = pressure_sensor
Last edited by KenWittlief : 05-02-2004 at 09:15.
|