Edge Trigger Code

hi every one..

i want to make a up-down counter using 8051..
two switches are connected with UC.
one for up counting and one for down counting..
now the problem is that if i press one switch only at once it count correctly but if
switch is not released then it will not count only for once.....it count continuosly untill the switch is released.
i want to make it edge triger mean if a switch is pressed it will count when switch is released. if switch is hold for long time ,it must have to count only once...

i need c code or any algorithem ..

i m using keil c compiler..

thnx

Replies

  • Harshad Italiya
    Harshad Italiya
    qaisarpk1
    hi every one..

    i want to make a up-down counter using 8051..
    two switches are connected with UC.
    one for up counting and one for down counting..
    now the problem is that if i press one switch only at once it count correctly but if
    switch is not released then it will not count only for once.....it count continuosly untill the switch is released.
    i want to make it edge triger mean if a switch is pressed it will count when switch is released. if switch is hold for long time ,it must have to count only once...

    i need c code or any algorithem ..

    i m using keil c compiler..

    thnx

    That is called KEY DEBOUNCE.

    what have you written? something like that? this is only if your switch is connected with Ground and you detect 0 at controller side.

    if(!SWITCH1)
    {
    count++;
    }

    Right?

    you can write
    while(!SWITCH) // in this case your execution waits untill you release the Key.
    {
    count++
    }

You are reading an archived discussion.

Related Posts

I am 4th year compurt science student.I have to submit details about the topic "skipfish" for my seminar. Please help me by providing me the details.Hope there will be aresponse...
hi everyone.. I am just a newbie in this forum, looking forward to meeting people from here and make friends if possible 😀 _________________
What are you seeing here...😡
Can anyone explain in detail what actually DLNA and what are its application? Does it need wi-fi to stream to PC using DLNA?
CEans, I stumbled upon uBuntu Forums apps in Chrome Web Store. Once you install the app, it appears in every new blank tab that you open and clicking on the...