AnalogRead and IR Obstacle Avoidance Sensor

Hi ,

I've got an Obstacle Avoidance Sensor and I want the Microcontroller to identify if there is no signal coming from the sensor and take an action based on that. for example, if the sensor detects an object then blink the LED for a period of time , but if there's no feedback as if there's no object in front of the sensor , then the LED should always stays ON. I hope the idea is clear.

note: I have tried multiple approaches by connecting the sensor to the PWM pins or the Analog ones, but it didn't work and I think it's because I have to use or Functions so the Microcontroller could receive the signal coming from the sensor.

this is the sensor I'm using
http://www.etechpk.net/wp-content/uploads/2016/02/SKU072960-1.jpg

as you figured I'm a newbie, and I'm looking forward to learn.

Thank you!

I hope the idea is clear.

Clear, but not possible. The Arduino can not see if there is nothing attached to a pin. Any attempt to read a pin with nothing attached to it will return garbage data.

The Arduino, rightfully, assumes that you will not be f**king around removing stuff while it is running.

PaulS:
Clear, but not possible. The Arduino can not see if there is nothing attached to a pin. Any attempt to read a pin with nothing attached to it will return garbage data.

The Arduino, rightfully, assumes that you will not be f**king around removing stuff while it is running.

I dont want the sensor to be unattached. the senor is connected , but it didn't detect any thing therefor there's no feedback to controller because there is no obstacle.

No feedback as in the output is 0V, or 5V, or it's just not driven, where by you could use a pullup or pulldown resistor to create a 0V or 5V input to signal no output.?

CrossRoads:
No feedback as in the output is 0V, or 5V, or it's just not driven, where by you could use a pullup or pulldown resistor to create a 0V or 5V input to signal no output.?

I really don't know, I'm using only Arduino mega and the sensor is directly connected to it.

Well, what's the reading you get when "nothing" is being detected?

CrossRoads:
Well, what's the reading you get when "nothing" is being detected?

it's 0 V

So,

void loop(){
if (analogRead(A0) <= 15){ // allow for some noise on the signal
digitalWrite (ledPin, HIGH);
}
else {
for (x=; x<5; x=x+1){  // 1 second of blinking
digitalWrite (ledPin, LOW);
delay (100);
digitalWrite (ledPin, HIGH);
delay(100);
}
digitalWrite (ledPin, LOW);
}

Build up from there.

for (x=;Build up from here?