Problem on Digital Read.

Hello Guys,

i am facing the Problem on Digital Read Function.
i am Read the digitalpin number =2;
Whenever i am inserted the interlock this value is going to 0 to 1 perfectly . but whenever i am removing the interlock they are taking the 12-16 sec to the Print or going the value 1 to 0.

i am not inserted any delay then Why i am getting so much delay i don’t know .
Please Tell me the solution.

i am using the arduino nano board.

Best Regards,
Seggi.

Sounds like the pin is floating (not connected to anything). A floating pin's state is undefined. This can be fixed by adding a pullup or pulldown resistor, as appropriate, to force the pin to a known state when not connected otherwise.

Post a schematic of your circuit for better help.

Hi Seggi, I take it "the interlock" is some kind of physical and electrical connection on your device - I don't know, since the term 'interlock' is somewhat ambiguous here. Well if it a physical connection, you can probably cure the floating numbers by putting a 100K resistor between the pin and ground.

Hello,

a interlock is a physical device they are used for the sorting purpose. i am making a simple circuit in this circuit only the +5V is connected to 4.7k resistor . and capacitor one terminal is connected to +5v and second is gnd.

and d2 pin is open whenever i am inserted the interlock they sorted and +5v is going to the digital pin and else 0v is going to digital pin

Best Regards, Seggi.

A schematic diagram would help you get the help you need. Depending on its value and how you have connected it, the capacitor could explain the problem. Here's how you can help.

Explain what you are seeking to do, rather than use imprecise / ambiguous term "interlock" ("a interlock is a physical device they are used for the sorting purpose".-> in English this does not explain anything at all)

Give us a diagram of the circuit so it is clear what you have wired.

I'd love to help if you can provide enough info

Hello Guys,

ok,below posted the circuit diagram.

12.jpg

Here is the diagram that seggi drew (modified to remove distortion and color confusion):

The thing you are calling an 'interlock' we call a 'jumper pin' in English technical jargon. Problem is, I still don't see what it does! The circuit 'above' the interlock is a RC filter, but it's on a constant DC source, so it doesn't have much effect, except to limit the current into D2. D2 will read HIGH if you do digitalRead(d2).

So here is a diagram of my suggestion above (reply #2):

The resistor I added is called a ‘pull down’ resistor, and is used to pull inputs down to ground when they are not connected to anything else. 100K is an approximation. In your real circuit, you may need more or less ohms.

Thanks you so much guys,

Now they works perfectly.

once again Thank you so much guys to helping me .

Best Regards,
Seggi.

And, if it wasn't clear:

When you have a pin that is an input... and it's connected to a switch that may be on or off (assuming off = not connecting the pin to something else) or it otherwise might not be electrically connected to the rest of the circuit, the pin is said to be floating. A "floating" pin will read random values, because it will pick up ambient electromagnetic fields (this is the basis of how antennas work).

It is unclear why you have the 4.7k resistor and capacitor there - they don't look like they're doing anything for you. I suspect you meant to put them somewhere else to get some sort of RC delay, or filter noise, or something? But that's the wrong place for them for that purpose.

Usually when working with a switch, you reverse the logic, so the switch connects the pin to ground - then you can set pinMode(pin,INPUT_PULLUP) and use the internal pullup in the arduino to pull it up to vcc when the button isn't pressed, saving you an external part.

Hello ,

for that place i am placing the resistor and capacitor because the filtering purpose.

I don't think there's any need to use capacitor or pull up resistor. Instead simply use pinMode(pin,INPUT_PULLUP); that will work perfectly fine.

If you want to use capacitor for filtering purpose then place it between +5V and GND of Arduino, and if you are powering up your Arduino with +12V then you can place a capacitor there as well.

I normally place 1000uF capacitor across +12V and 100uf across +5V and never used pull up resistor with Arduino.

jackthom41: I don't think there's any need to use capacitor or pull up resistor. Instead simply use pinMode(pin,INPUT_PULLUP); that will work perfectly fine.

If you want to use capacitor for filtering purpose then place it between +5V and GND of Arduino, and if you are powering up your Arduino with +12V then you can place a capacitor there as well.

I normally place 1000uF capacitor across +12V and 100uf across +5V and never used pull up resistor with Arduino.

There's certainly no need for a pullup resistor here, since a pull-down is what is needed...

BTW an interlock is a physical device which when removed renders a dangerous circuit or machine inoperative so that it is safe to do maintainance on it.

This implies a safety-critical application for which the Arduino is not in anyway certified for.