4754 views|6 replies

81

Posts

0

Resources
The OP

Key digital tube flashing problem [Copy link]

Hi guys, my problem is that there are 5 buttons and 5 digital tubes on the board. Since I can't add capacitors in the circuit, I use delay anti-shake when pressing the button. But the program thinks it is a continuous key press, which causes the digital tube to go black when the program is running continuously and the delay is released. The digital tube will light up normally. Please give me a good idea. I will be very grateful.
This post is from Embedded System

Latest reply

The method on the 5th floor is correct. In fact, scanning the keyboard can also be done in the timer interrupt.  Details Published on 2009-8-16 20:51

74

Posts

0

Resources
2
If continuous keystrokes are allowed, for example, if they are pressed continuously (usually 3 to 4 times per second like a computer keyboard), let me give you an idea of how to respond. There is a discussion on keyboard anti-shake in this section. You can take a look at sbit key1=P1^0; .... void timer0 interruput 1 { if(key1==0) { delayms(10); if(key1==0)//If it is still pressed after 10 milliseconds, the key is valid { //Key response } } }
This post is from Embedded System

76

Posts

0

Resources
3
The key must have a global flag, representing the key status, such as pressed, released, continuous key, etc. The continuous key is set when the key is pressed and the continuous key time is met. The delay program follows, and the digital tube refresh is done in the timer interrupt service program, so it will not be affected by the key delay code.
This post is from Embedded System

72

Posts

0

Resources
4
When using software to prevent jitter, you should use whether the key has been released as the standard for judging whether the key has been pressed if(!k){ delay() //Delay to wait for the key to stabilize while(!k); //If the key is not released, let it stop and do not execute the following program until your key is released. 。 。 。 。 //Write the key response program below }
This post is from Embedded System

69

Posts

0

Resources
5
The above is right. After you press the key, if you don't release it, the digital tube is black and does not display anything? You should continue to send data while pressing the key. while (1) { .................. //Send data} if (!k) { delay() // Delay to wait for the key to stabilize if (!k) { . . . . . . . . //Send data to the digital tube} while (!k); // If the key is not released, let it stop and do not execute the following program until you release the key. The reason for the continuous flashing should be the control of the delay time. Usually 10MS
                  

This post is from Embedded System

63

Posts

0

Resources
6
Your digital tube display program should be implemented using a timer interrupt, and the timer overflow should be set to about 10MS. This will prevent the main program from pausing and causing the digital tube to flicker.
This post is from Embedded System

81

Posts

0

Resources
7
The method on the 5th floor is correct. In fact, scanning the keyboard can also be done in the timer interrupt.
This post is from Embedded System

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list