Use the serial port to input integer simple code

Publisher:SparkCrafterLatest update time:2015-06-19 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
At first I wanted to use interrupts, but in the end I ended up using code. #include #define uchar unsigned char #define uint unsigned int uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};// Digital table uchar num1; //Display tens digit uchar num0; //Display units digit  //--------------------------------- void delay(uint k) //Delay {  while(k--); } //----------------------------- void main() { uchar j; TMOD=0x20; TH1=0xfd; TL1=0xfd; TR1=1; SCON=0x50; while(1) {   while(RI==1) //Input the first number {  j=SBUF;  num1=j-'0';  RI=0;  while(RI==0); // Enter the second number  j=SBUF;  num0=j-'0';  RI=0;  }  P0=tab[num1];  P2=0xfd;  delay(100);  P0=tab[num0];  P2=0xfe;  delay(100);  } }










































Reference address:Use the serial port to input integer simple code

Previous article:"Screen-style" sound and light electronic keyboard program
Next article:RS-485 multi-machine communication program (host side)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号