用sbit定义成led后,就不能点亮数码管了,请各位大虾为小弟指点迷津?

2019-07-15 09:16发布

小弟新手一枚,最近在学习普中科技推出的一款51的单片机开发板,在点亮静态数码管的时候遇到一个问题,程序一与程序二编译均无报错,程序一能够点亮数码管,但是我将P0口用sbit定义成led后,就不能点亮数码管了,请各位大虾为小弟指点迷津,谢谢一:#include "reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;
u16  smgduan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff};
  void main()
{
   P0=smgduan[0];
   while (1)
   {}
}

二:#include "reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;
sbit led=P0;
u16  smgduan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff};
  void main()
{
  led=smgduan[0];
   while (1)
   {}
}


2.png
1.png
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。