这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » 龙鼎山 MCU DIY进程帖(电路板的缺陷)

共12条 2/2 1 2 跳转至
菜鸟
2011-12-05 18:19:44     打赏
11楼

数码管显示!一天计时器,图片以后补!
不知道为什么数码管比较暗!(段少时比较亮)
刚才数码管的位老是乱串!
一查!是单片机的P2.1脚夹不紧!
[hid]
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar tcount,s,min,hour;
uchar code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};
uchar disbuf[]={0,0,0,0,0,0,0,0};
uchar code place[]={0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00};


void main()
{ uchar i,k;
  TMOD=0X01;
  ET0=1;
  EA=1;
  TR0=1;
  tcount=0;s=0;
  min=0;hour=0;
  while(1)
  { 
    if(!TF0)
    {
  disbuf[1]=dispcode[s/10];
  disbuf[0]=dispcode[s%10];
  disbuf[2]=dispcode[10];
  disbuf[4]=dispcode[min/10];
  disbuf[3]=dispcode[min%10];
  disbuf[5]=dispcode[10];
  disbuf[7]=dispcode[hour/10];
  disbuf[6]=dispcode[hour%10];}
  for(i=0;i<20;i++)
  {
  for(k=0;k<8;k++)
  { P2=place[k];
   P0=disbuf[k];
 P0=0x00; 
  }
  }}
}

void time1() interrupt 3
{
  TH0=(65536-50000)/256;
  TL0=(65536-50000)%256;
  TF0=0;
  tcount++;
  if(tcount==20)
  { tcount=0;
 s++;
 if(s==60)
 {  s=0;
    min++;
    if(min==60)
    { min=0;
   hour++;
   if(hour==24)
   hour=0;
    }
 }
  }
}

数码管.rar


菜鸟
2011-12-06 16:26:40     打赏
12楼

近期有时间写写程序!刚学的!
点阵的程序!与板子对应!
点阵.rar
取字模软件
字模.rar
本想弄一个绿屏红字的!没想到板子的P0口,对点阵无法复用!造成效果无法实现!


#include<reg51.h>
#define uchar unsigned char

/*uchar code table[11][8]={
             {0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38},//0
       {0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x38},//1
       {0x00,0x38,0x44,0x04,0x04,0x38,0x40,0x7c},//2
       {0x00,0x38,0x44,0x04,0x38,0x04,0x44,0x38},//3
       {0x00,0x08,0x18,0x28,0x48,0x7C,0x08,0x08},//4
       {0x00,0x7C,0x40,0x78,0x04,0x04,0x04,0x78},//5
       {0x00,0x38,0x44,0x40,0x78,0x44,0x44,0x38},//6
       {0x00,0x7C,0x04,0x08,0x10,0x10,0x10,0x10},//7
       {0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x38},//8
       {0x00,0x38,0x44,0x44,0x3C,0x04,0x44,0x38},//9
       {0x00,0xf8,0x80,0x80,0xfe,0x80,0x80,0xf8}//山

      };*/
uchar code distable[11][8]={
        {0xFF,0xC7,0xBB,0xBB,0xBB,0xBB,0xBB,0xC7},//0
        {0xFF,0xEF,0xCF,0xEF,0xEF,0xEF,0xEF,0xC7},//1
        {0xFF,0xC7,0xBB,0xFB,0xFB,0xC7,0xBF,0x83},//2
        {0xFF,0xC7,0xBB,0xFB,0xC7,0xFB,0xBB,0xC7},//3
        {0xFF,0xF7,0xE7,0xD7,0xB7,0x83,0xF7,0xF7},//4
        {0xFF,0x83,0xBF,0x87,0xFB,0xFB,0xFB,0x87},//5
        {0xFF,0xC7,0xBB,0xBF,0x87,0xBB,0xBB,0xC7},//6
        {0xFF,0x83,0xFB,0xF7,0xEF,0xEF,0xEF,0xEF},//7
        {0xFF,0xC7,0xBB,0xBB,0xC7,0xBB,0xBB,0xC7},//8
        {0xFF,0xC7,0xBB,0xBB,0xC3,0xFB,0xBB,0xC7},//9
        {0xFF,0xEF,0xEF,0xEF,0x6D,0x45,0x39,0x01}//山
       };
void delay(uchar z)
 {
  uchar x,y;
  for(x=z;x>0;x--)
   for(y=250;y>0;y--);
 }

main()
 {
  uchar i,j,k,h;
  while(1)
   {
    for(i=0;i<11;i++)
     {  for(h=0;h<90;h++)
      {
      k=0x80;
      for(j=0;j<8;j++)
       {
        P0=k;
        P2=distable[i][j];
        delay(20);
        P2=0xff;
        k=k>>1;
       }
      }
     }
   }
 }


共12条 2/2 1 2 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]