时间有点仓促~ 最近忙着考试~ 找工作~ 一大堆事忙~ 哈哈 板子焊好了没怎么上来发帖~
感觉有点对不起EEPW网站,再次感谢EEPW对我们在校学生及广大电子爱好者提供了这次这么好的动手机会~
这张就是板子焊好的面貌~·~~~ 先上一张LOOK LOOK~
这张就是单位数码管显示~ 哈哈
这张就是动态扫描数码管显示~
接下来附上几个实验程序吧~
1。流水灯:
#include"reg52.h"
unsigned char counter=0;
unsigned char num = 0xfe;
void initT0()
{
TMOD = 0X01;
TH0 = 0X3C;
TL0 = 0XB0;
EA = 1;
ET0 = 1;
TR0 =1;
}
void main()
{
num = 0XFE;
initT0();
while(1){};
}
void timer0() interrupt 1
{
counter++;
TH0 = 0X3C;
TL0 = 0XB0;
if(counter > 10)
{
counter = 0;
num = num << 1;
num+=1;
P1 = num;
if(num == 0XFF)
{
num = 0XFE;
}
}
}
2。数码管显示:
#include"reg52.h"
sbit P37 = P3^7;
unsigned char num=0,a=0;
unsigned char code dis[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void initT0()
{
TMOD = 0X01;
TH0 = 0XFA;
TL0 = 0X24;
EA = 1;
ET0 = 1;
TR0 =1;
}
void main()
{
P37 = 1;
initT0();
while(1){};
}
void timer0() interrupt 1
{
TH0 = 0XFA;
TL0 = 0X24;
num++;
a++;
if(num > 7)
{
num = 0;
}
if(a > 7)
{
a = 0;
}
P2 = num;
P0 = dis[a];
}
3。矩阵键盘:
#include"reg52.h"
char h,l,key;
unsigned char switchcode[16] = {0xe7,0xd7,0xb7,0x77,0xeb,0xdb,0xbb,0x7b,0xed,0xdd,0xbd,0x7d,0xee,0xde,0xbe,0x7e};
unsigned char code dis[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void keydelay(unsigned char u)
{
unsigned char i;
for(;u>0;u--)
for(i=124;i>0;i++);
}
char keyscan(void)
{
unsigned char cord_h,cord_l;
P3 = 0x0f;
cord_h=P3 & 0x0f;
if(cord_h!=0x0f)
{
keydelay(1);
cord_h=P3 & 0x0f;
if(cord_h!=0x0f)
{
P3=cord_h | 0xf0;
cord_l=P3 & 0xf0;
key = (cord_h+cord_l);
return(key);
}
}
return(0xff);
}
char keydown(void)
{
unsigned char i;
P3=0x0f;
if(P3!=0x0f)
{
i = keyscan();
return i;
}
return 0;
}
void main(void)
{
P3 = 0X0F;
P2 = 0X00;
while(1)
{
key = keydown();
switch(key)
{
case 0xe7:P0 = dis[0];break;//0 按下相应的键显示相对应的码值
case 0xd7:P0 = dis[1];break;//1
case 0xb7:P0 = dis[2];break;//2
case 0x77:P0 = dis[3];break;//3
case 0xeb:P0 = dis[4];break;//4
case 0xdb:P0 = dis[5];break;//5
case 0xbb:P0 = dis[6];break;//6
case 0x7b:P0 = dis[7];break;//7
case 0xed:P0 = dis[8];break;//8
case 0xdd:P0 = dis[9];break;//9
}
}
}
视频虽然也录制了~ 但是先不穿上来了~因为录的比较疯狂~以免影响不好 哈哈~
接下来我会继续完成板子上的程序,希望能和EEPW论坛上的朋友们一起学习,一起分享我们学习的快乐~