51單片機(jī)C語言程序(四)鍵盤 數(shù)碼管 跑表程序
數(shù)碼管前三位顯示一個跑表,
從000到999之間以1%秒的速度運(yùn)行,
當(dāng)按下一個獨(dú)立鍵盤時跑表停止,
松開手后跑表繼續(xù)運(yùn)行(用定時器設(shè)計表)
#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
sbit s2=P3^4;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,
0x76,0x79,0x38,0x3f,0};
uchar flag,t0,ge,shi,bai;
uint shu;
void init();
void display(uchar aa,uchar bb,uchar cc);
void delay(uint z)
{
}
void main()
{
}
void init()
{
}
void timer0() interrupt 1
{
}
void display(uchar aa,uchar bb,uchar cc)
{
}
程序二
數(shù)碼管前三位顯示一個跑表,
從000到999之間以1%秒的速度運(yùn)行,
當(dāng)按下一個獨(dú)立鍵盤時跑表停止,
松開手后跑表繼續(xù)運(yùn)行(用定時器設(shè)計表)
三個獨(dú)立鍵盤實現(xiàn)按下第一個時計時停止,按下第二個
時計時結(jié)束,按下第三個是計數(shù)值清零從頭開始
#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
sbit s2=P3^4;
sbit s3=P3^5;
sbit s4=P3^6;
sbit s5=P3^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,
0x76,0x79,0x38,0x3f,0};
uchar flag,t0,ge,shi,bai;
uint shu;
void init();
void display(uchar aa,uchar bb,uchar cc);
void delay(uint z)
{
}
void main()
{
}
void init()
{
}
void timer0() interrupt 1
{
}
評論