
视频地址:http://player.56.com/v_65020944.swf
#include<reg52.h>
#include<intrins.h>
#define unchar unsigned char ;
void delay(unsigned int z);
unchar LED,k;
void main()
{
P1=0xfe;
LED=P1;
while(1)
{
for(k=7;k>0;k--)
{
P1=_crol_(LED,1);
delay(500);
LED=P1;
}
for(k=7;k>0;k--)
{
P1=_cror_(LED,1);
delay(500);
LED=P1;
}
P1=0xef;
for(k=8;k>0;k--)
{
P1=_cror_(LED,1);
delay(500);
LED=P1;
}
}
}
void delay(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--)
{}
}

#include<reg52.h>
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P37=P3^7;
#define unchar unsigned char
#define unint unsigned int
unchar shuzi,mbn;
unchar code tabol[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71} ;
void delay(unint z);
void main()
{
while(1)
{
P2=0X00;
P37=1;
P0=tabol[1];
P37=0;
delay(500);
P2=0X1;
P37=1;
P0=tabol[2];
P37=0;
delay(500);
P2=0X2;
P37=1;
P0=tabol[3];
P37=0;
delay(500);
P2=0X3;
P37=1;
P0=tabol[4];
P37=0;
delay(500);
P2=0X04;
P37=1;
P0=tabol[5];
P37=0;
delay(500);
P2=0X5;
P37=1;
P0=tabol[6];
P37=0;
delay(500);
P2=0X6;
P37=1;
P0=tabol[7];
P37=0;
delay(500);
P2=0X7;
P37=1;
P0=tabol[8];
P37=0;
delay(500);
}
}
void delay(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=120;y>0;y--);
}

1*4独立按键和数码管显示
视频地址:http://player.56.com/v_65042258.swf
程序代码如下:
#include<reg52.h>
sbit P30=P3^0;
sbit P31=P3^1;
sbit P32=P3^2;
sbit P33=P3^3;
sbit D1=P1^0;
sbit D2=P1^1;
sbit D3=P1^2;
sbit D4=P1^3;
sbit P20=P2^0;//wei
sbit P21=P2^1;
sbit P22=P2^2;
sbit P37=P3^7;//duan
#define unchar unsigned char
#define unint unsigned int
unchar code tabol[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unchar tmap,nmb;
void shuma_key();
unchar keyscan();
void delay(unint z)
{
unint x,y;
for(x=z;x>0;x--)
for(y=210;y>0;y--);
}
void main()
{
while(1)
{
keyscan();
shuma_key();
}
}
unchar keyscan()
{
tmap=P3;
tmap=tmap&0x0f;
if(tmap!=0X0f)
delay(10);
{
tmap=tmap&0x0f;
if(tmap!=0X0f)
{
switch(tmap)
{
case 0x0e:nmb=1;
break;
case 0x0d:nmb=2;
break;
case 0x0b:nmb=3;
break;
case 0x07:nmb=4;
break;
}
}
while(tmap!=0x0f)
{
tmap=P3;
tmap=tmap&0x0f;
}
}
return nmb;
}
void shuma_key()
{
if(nmb==1)
{
P2=0X0;
P37=1;
P0=tabol[1];
P37=0;
D1=0;
}
if(nmb==2)
{
P2=0X01;
P37=1;
P0=tabol[2];
P37=0;
D2=0;
}
if(nmb==3)
{
P2=0X02;
P37=1;
P0=tabol[3];
P37=0;
D3=0;
}
if(nmb==4)
{
P2=0X03;
P37=1;
P0=tabol[4];
P37=0;
D4=0;
}
}
回复
有奖活动 | |
---|---|
【EEPW电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 |