Go Down

Topic: Need delay after digitalRead to make variables work (Read 14782 times) previous topic - next topic

John_S

Quote
I was wondering if the OP had tried to move the delay to the very bottom of loop()

There would be no change. There are no other delay()s in the loop, so it would at the delay(20) at the bottom of the loop in a matter of microseconds.

Brad Burleson


There would be no change. There are no other delay()s in the loop, so it would at the delay(20) at the bottom of the loop in a matter of microseconds.


I was simply trying to address the OP's concern about a problem with digitalRead - if the delay was moved the problem really can't be that digitalRead needs a delay, can it?

Brad (KF7FER)

jfhaugh



There would be no change. There are no other delay()s in the loop, so it would at the delay(20) at the bottom of the loop in a matter of microseconds.


I was simply trying to address the OP's concern about a problem with digitalRead - if the delay was moved the problem really can't be that digitalRead needs a delay, can it?

Brad (KF7FER)


I'm sure he'd have come up with some other bogus reason why the code didn't work, or if it did work, some bogus reason why it did.

jfhaugh



My suggestion is you be an adult, take your licks, learn your lesson, and show a bit of humility.

Your choice.

Here again I have accepted that caps or pullups might fix the problem but you have to remember that I was arguing that bounce, in and of itself and not resulting noise from one or more switch clicks, did not cause the problem.  I think I argued fair and was not rude.  I just re-read the entire thread and I challenge you to find where I was out of line.


You got lucky that it was the problem Nick suggested, though the solution to the problem was the same either way.  You'll also note that I explained that capacitors serve more than one purpose.  I buy them by the 100's -- very handy devices to have on hand.

You seem to think that Nick and I need to give you -- a hobbyist with NO understanding of real electronic circuits -- an education in electrical engineering in order for us to have our advice accepted.  Did it occur to you that accepting our advice might be a nice first step as a way to show gratitude for the time we're investing?

I'm with Nick -- you're a waste of time.  I'm going to go find the "Ignore" feature and give you the distinction of being the first person on this board that I ignore.

freakdaddy


You got lucky that it was the problem Nick suggested, though the solution to the problem was the same either way.  You'll also note that I explained that capacitors serve more than one purpose.  I buy them by the 100's -- very handy devices to have on hand.

Right but I learned more buy discussing it more.


You seem to think that Nick and I need to give you -- a hobbyist with NO understanding of real electronic circuits -- an education in electrical engineering in order for us to have our advice accepted.

No I don't think that at all.  I don't think I achieved an education in electrical engineering from either of you but Nick did help me understand one important concept.


  Did it occur to you that accepting our advice might be a nice first step as a way to show gratitude for the time we're investing?

I accepted advice.  I just didn't want to drop it without understanding what was happening.


I'm with Nick -- you're a waste of time.  I'm going to go find the "Ignore" feature and give you the distinction of being the first person on this board that I ignore.

Do what you need to do.  I don't know why you guys got so bent out of shape over it.

freakdaddy


You got lucky that it was the problem Nick suggested, though the solution to the problem was the same either way.  You'll also note that I explained that capacitors serve more than one purpose.  I buy them by the 100's -- very handy devices to have on hand.


Actually I didn't get lucky.  I knew for a fact that the switches weren't bouncing causing the behavior that I saw.  I understand the code I wrote and knew that bounce was handled.  Many posters kept claiming it was bounce.  I insisted that bounce was not the issue and that made Nick and you mad.  I was right in the end but I did fail to recognize that noise was the source of the problem.  I appreciate what Nick did and have said so.  Never once did I let my temper flare at either of you. 

jfhaugh



You got lucky that it was the problem Nick suggested, though the solution to the problem was the same either way.  You'll also note that I explained that capacitors serve more than one purpose.  I buy them by the 100's -- very handy devices to have on hand.


Actually I didn't get lucky.  I knew for a fact that the switches weren't bouncing causing the behavior that I saw.  I understand the code I wrote and knew that bounce was handled.  Many posters kept claiming it was bounce.  I insisted that bounce was not the issue and that made Nick and you mad.  I was right in the end but I did fail to recognize that noise was the source of the problem.  I appreciate what Nick did and have said so.  Never once did I let my temper flare at either of you. 


No, you didn't know for anything that it wasn't switches bouncing.

But that's besides the point, you equally ignored my comments about power on the supply rail, which is likely what caused the noise Nick captured.  When the current flowing through a circuit changes, the voltage at different points within that circuit changes.

Physical circuits are not ideal circuits.  You cannot assume they work perfectly, which is what you did.  And you've learned nothing at all from this entire exercise because now you think "oh, noise", and the next time it could be something entirely different.

And sorry I responded.  I've been fighting with a Fio and haven't had the time to add you to "Ignore".

freakdaddy


No, you didn't know for anything that it wasn't switches bouncing.

Yes I knew exactly that.  That's why I wrote the code the way I did.  Step through it and you will see that switch bounces don't effect it.  That's why I was so adamant that it couldn't be the cause.  And I was right.


But that's besides the point, you equally ignored my comments about power on the supply rail, which is likely what caused the noise Nick captured.  When the current flowing through a circuit changes, the voltage at different points within that circuit changes.


Yes I did because I didn't understand.  It's no reason to be mad.


Physical circuits are not ideal circuits.  You cannot assume they work perfectly, which is what you did.

100% true.

And you've learned nothing at all from this entire exercise because now you think "oh, noise", and the next time it could be something entirely different.

I've learned and I'll never stop learning.


And sorry I responded.  I've been fighting with a Fio and haven't had the time to add you to "Ignore".

It's really nothing to be that mad about.

freakdaddy

Well for what's it's worth.  I went the route of using external pullups and that has solved the problem.  I may still add caps for filtering purposes.  Nick if your listening, THANK YOU!!!  Also I bought that logic analyzer that you showed me.  Thanks again!

Go Up