1.依次显示0~9数字
2.源码
//C51 PROGRAM.
//latest revise:2009-12-20
//by:alex shoal
//email:alex.shoal@gmail.com
#include <reg51.h>
#include <stdio.h>
#include <string.h>
#include <intrins.h>
void delayms(unsigned int k)
{
unsigned char n;
while(k--)
{
for(n=0;n<=110;n++);
}
}
void init()
{
SM0=0;
SM1=1;
SM2=0;
REN=1;
TI=0;
RI=0;
PCON=PCON&0X80;
TH1=0XF3;
TL1=0XF3;
TR1=1;
}
void delay()
{
_nop_();_nop_();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();
}
//sent one byte to TXD
void sent_byte(unsigned int k)
{
P1=k;
delayms(200);
}
void main()
{ int i;
init();
delay();
while(1)
{
for(i=0;i<10;i++)
sent_byte(i);
}
}
3.电路图