??? 09/24/04 02:21 Read: times |
#78049 - You got it Responding to: ???'s previous message |
I think I've got it, here's the new code and it appears to be working. Yes, excellent! Looking at your code it looks like you completely understand the concept of debouncing and came up with a functional implementation. That's great considering the professor had you thinking that a debounce was nothing more than a delay. :) Just a couple suggestions to optimize things if you're interested. 1. You can get rid of the "MOV A,50H" which comes right after the "DJNZ R6" instruction. It isn't necessary because if A wasn't already the same as the value in 50H then the CJNE inside the DJNZ loop would have aborted the loop and jumped back to RESET1. 2. What you are doing now is checking for the current state of the switch and debouncing it and then checking to see if the switch was actually pressed with your JNZ RESET1 line after the debounce. This will work but usually one checks at the beginning whether or not the key is pressed and only does the debounce if the key is pressed. I probably wouldn't change your code at this point since it works but I just thought I'd let you know how it is usually done. 3. While this is just nitpicking and doesn't make any technical difference, it is usually a good idea to put a blank line between sections of code. I'd probably put a blank line before the RESET line, the READ line, after the JNZ RESET1 line, before the SET and before CLEAR line. That just makes it a little more readable. No big deal... it's a matter of personal style more than anything. Anyway, great work Lisa. Regards, Craig Steiner |