leddisplay的对应代码.docVIP

  • 6
  • 0
  • 约1.1千字
  • 约 2页
  • 2017-08-22 发布于江苏
  • 举报
leddisplay的对应代码

我所使用的实验板中数码管是共阴的,电路图如下所示 数码管中八个LED分别对应于a b c d e f g dp,按照左高位右地位排列就是dp g f e d c b a。 由于是共阴的数码管,阴极连到了一起,所以想要点亮相应的LED就必须得使相应的位置1,比如要出现数字1,就要使b和c位为1而其他位为0,也就是十六位的数06,如此就可推算出由0到7的相应a到dp的组合(就是显示码),分别为0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f共六个。当然也可以继续推算出8 9 10 b c E的相应代码。 现在要做的就是写一个c51程序,把所推算的显示码送到数码管中,看看显示码和相应的数字是否符合。 代码如下 /***************************************************** Project : LED display Version : V1 Date??? : 2009_0226 Author? : Lemy Wong??????????? Company : N/A???????????????????? Comments: using array to change what the LED display displays Chip type?????????? : AT89S52 Program type??????? : Application Clock frequency???? : 12 MHz *****************************************************/ #include reg52.h void delay()?????? //function of delaying { ??? int n = 30000; ??? while(--n); } main() { ??? int display_code[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};? //initialize an array ??? int i; ??? P2 = 0x00;??????????????? //get the first LED display work ??? for(i = 0 ;i = 7; i++) ??? { ??????? P0 = display_code[i]; ??????? delay(); ??? }

文档评论(0)

1亿VIP精品文档

相关文档