CrazyEngineers
  • Edge Trigger Code

    qaisarpk1

    Member

    Updated: Oct 26, 2024
    Views: 1.2K
    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
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Harshad Italiya

    MemberJun 21, 2011

    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++
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register