Society of Robots - Robot Forum
Software => Software => Topic started by: icoms8 on August 16, 2009, 03:39:17 PM
-
Im trying to understand the basics of c++ and i want to run a photoresister on the adrunio, but i dont know the code that stores data. Can some one tell me it or give me a site that has the basic codes on it?
-
so you want to store the sensor reading in memory?
-
well i dont know. All im doing is use the if stament so if its dark a led turns on.
-
then thats easy,
IF photo resistor pin<threshold
led pin high...
-
sorry im asking such stupid questions, but what is threshold?
-
Well threshold is a range where something can occur. In this case, the threshhold values are values that you consider to be dark.
-
about thresholds:
say your sensors reads values between 1 and 100.
you point it at a white floor and it reads 90 you point it at a black line on the floor (say electical tape) and it reads 20
a good "threshold" between the two values would be 55
as for storing values
you could always store the value in a variable
something like this:
sensorValue = readSensor();
you can then use sensorValue for whatever you want