the above code works perfectly by usb and by external power supply ,Were when the sensor (limit switch) is nearrer the board the said programe works correctly but when the sensor connected to door the out put flickers randomly.Searched forum,googled no result need kind help from learned members and thankful in advance.
nazeem:
Were when the sensor (limit switch) is nearrer the board the said programe works correctly but when the sensor connected to door the out put flickers randomly.
What sort of sensor is it? (A switch? A PIR sensor?)
What's the difference between the two scenarios - is it the same circuit with longer wires, or are there any other differences? Is it the identical 'sensor' (switch, whatever) connected in both cases?
If the answer is that everything's exactly the same and you're just using longer wires, and the sensor is something other than a switch, I suppose you're probably picking up interference. What sort of wires are you using?
Thankyou so much PeterH
For you kind intereset as the sensor is a switch and wires are normal flexible connecting wires at about ten feet length please see image
Yes exactly the switch is connected in .NC (normally close) condition as per the above said code the output must go high when switch goes to normal open condition,as of the output flickering randomly at normally close condition , simply two wires connected to switch check the image.
nazeem:
Yes exactly the switch is connected in .NC (normally close) condition .. the output flickering randomly at normally close condition
That suggests that you have an intermittent break in the circuit - perhaps a broken wire or poor connection. You could track it down by monitoring the end-to-end resistance as you wiggle wires and connections until you find the cause, bearing in mind that the Arduino would pick up even very brief breaks which might not be obvious to a digital meter.
Goodmorning PeterH
Well checked the connections soldered' on PCB further checked the sensor wires and connections are intact,yet no result found as everything is correct but ouput flickering not stopping,unable to find the reason-Is there any problem in code?