Read proximity sensor

Hai this is Ravi from India. Im very new to arduino... Im working with a new project Read npn no proximity sensor status change detection.... 0 to 1 or 1 to 0..

Relay should active if any changes in proximity sensor from high to low or low to high..

If no change in proximity relay should low..

Pls help me

With regards

Ravi

Ravi, you need to take the first step and present your best effort to code this, even if you can only type into pseudocode what you want the code to do. Then we can help expand the code, and correct the syntax.

Q1. What type of proximity sensor you are using give part number.?
Q2.are you using any relay driver board ? or you made it your own board. ?
Q3. provide components part number like BC547, 5V or 12V or 24VDC relay.etc..
Q4. Provide brief about your application.

Regards
EJ LEDs
India

Note: 'npn' is a way of saying "Open Collector/Drain Output". That mean you need a pull-up resistor for that signal. Perhaps setting the input to INPUT_PULLUP will be sufficient.

Ravikumar1984:
Relay should active if any changes in proximity sensor from high to low or low to high..

If no change in proximity relay should low..

A change is a moment in time.

I assume what you really want to do is activate your relay for a certain time upon change of the sensor state.

Look at millis() based timing (Blink Without Delay example) and the State Change example, both available in the IDE.