|
楼主 |
发表于 2023-1-14 22:24:23
|
显示全部楼层
收获:可自由调控小灯管获得任意的字母或者数字
- #include <STC15F2K60S2.h>
- #define uchar unsigned char
- uchar code tab[]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90,0XFE};
- void disp(long int dat);
- void DelaySMG(unsigned int time);
- void main()
- {
- P2=0XA0;P0=0X00;
- P2=0X80;P0=0XFF;
- P2=0;
- while(1)
- {
- disp(52002023);
- }
- }
- void disp(long int dat)
- {
- int i;
- uchar str[8];
- str[0]=dat/10000000%10; //5
- str[1]=dat/1000000%10;//2
- str[2]=dat/100000%10;//0
- str[3]=dat/10000%10;//0
- str[4]=dat/1000%10;//2
- str[5]=dat/100%10;//0
- str[6]=dat/10%10;//2
- str[7]=dat/1%10;//3
- for( i = 0 ;i <8;i++)
- {
- P2 = P2&0x1f|0xC0;
- P0=0X01<<i;
-
- P2 = P2&0x1F|0xE0;
- P0=tab[str[i]];
-
-
- if(i==3)
- {
- P0=0XBF;
- }
- P2 = P2&0x1F;
- DelaySMG(100);
- P2=P2&0x1f|0xE0;P0=0XFF;
- }
-
- }
- void DelaySMG(unsigned int time)
- {
- while(time--);
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|