//实例 63:用 LED 数码显示器伪静态显示数字 1234#include // 包含 51 单片机寄存器定义的头文件 void delay(void) //延时函数,延时约 0.6 毫秒{ unsigned char i;for(i=0;i<200;i++) ; }void main(void){ while(1) //无限循环 { P2=0xfe; //P2.0 引脚输出低电平,DS0 点亮 P0=0xf9; //数字 1 的段码 delay(); P2=0xfd ; //P2.1 引脚输出低电平,DS1 点亮 P0=0xa4; //数字 2 的段码 delay(); P2=0xfb; //P2.2 引脚输出低电平,DS2 点亮 P0=0xb0; //数字 3 的段码 delay(); P2=0xf7; //P2.3 引脚输出低电平,DS3 点亮 P0=0x99; //数字 4 的段码 delay(); P2=0xff; } }
发表评论取消回复