Hello, I am trying to figure this out to add to a bigger project and then eventually a robot, I need to get a value from the IR Sensor (just an IR light next to an IR resistor) to measure two different values, one when it is close to a hard surface and one when it is far away (on top of table, off of table) I am getting about 3000-6000 on the serial monitor for on the table and about 10,000+ off the table. How to I make this control an LED. Have it turn on when the sensor is facing hard surface, turn off when facing open air. Thanks!

That works great! thank you. Say, what if I wanted to change the delay in between the time it checks to be 100 or even 10 and then just average it over a set period of time, say if its 10ms and then average those over 100ms so it is more accurate because i sometimes get random readings and I want to eliminate those because eventually it will be operating a motor in a more complicated sequence. thanks.

Well I am using the serial readout to initialize another function (right now it is to turn on a light but eventually will be more complicated with servos) and my problem is that i occcasionally get random numbers and i need to find a way to eliminate these random numbers so that the function only takes place when it really needs to. I just need a way to average 10 numbers from the serial monitor and then use them in/ to control this:

I don't understand hat the serial monitor has to do with the problem; it has no arithmetic capability.If you want to average 10 numbers on the Arduino, just do it the normal way; sum ten readings and divide by ten.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.