欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 我想實(shí)現(xiàn)按鍵次數(shù)顯示在數(shù)碼管上并發(fā)送到電腦上,但是串口助手上顯示的不是12345這... [打印本頁(yè)]

作者: tomorrow101    時(shí)間: 2019-12-28 10:11
標(biāo)題: 我想實(shí)現(xiàn)按鍵次數(shù)顯示在數(shù)碼管上并發(fā)送到電腦上,但是串口助手上顯示的不是12345這...
#include <reg52.h>
#include<stdlib.h>
#define uint unsigned long
#define uchar unsigned char
sbit led1 = P2^0; // 0 light
sbit led2 = P2^1;
sbit led3 = P2^2;
sbit led4 = P2^3;
uchar code table[]={0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90};

uint num,a;



sbit Key=P3^5;
void delayms(unsigned char t)
{
unsigned char i;
while(t--)
{
for(i=0;i<255;i++)
{
}
}
}
void display(unsigned long cnt)
{
       
                led1=0;               
                P0=table[(cnt%10000)/1000];       
                delayms(1);               
                P0=0XFF;               
                led1=1;               

                led2=0;               
                P0=table[(cnt%1000)/100];       
                delayms(1);               
                P0=0XFF;               
                led2=1;

                led3=0;               
                P0=table[(cnt%100)/10];       
                delayms(1);               
                P0=0XFF;               
                led3=1;

                led4=0;               
                P0=table[cnt%10];       
                delayms(1);               
                P0=0XFF;               
                led4=1;
               
}


void main(void)
{
unsigned char cnt=0;
SCON = 0x50;
TMOD |= 0x20;
TH1 = 0xFD;  
TR1 = 1;
delayms(1);
while(1)
{display(cnt);
if(Key==0)
{
delayms(10);
if(Key==0)
{
SBUF=cnt;
         cnt++;
while(TI==0);
TI=0;
while(Key==0);
}
}
}
} 我按獨(dú)立按鍵,從1 按到21但是顯示的卻是下面的數(shù)字,求大佬指教,怎么可以在電腦上顯示按鍵次數(shù)呢!





作者: 東111    時(shí)間: 2019-12-29 19:05
第一可能你選擇的是hex,第二可能波特率的問(wèn)題,第三注意是多少進(jìn)制的數(shù),第四注意字符型還是整型




歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1