欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
提供一個自動窗簾的51單片機程序(藍橋杯的題)
[打印本頁]
作者:
fuyun1208
時間:
2019-3-29 16:03
標題:
提供一個自動窗簾的51單片機程序(藍橋杯的題)
提供一個自動窗簾的51單片機程序(藍橋杯的題)
單片機源程序如下:
#include<reg51.h>
#include<time1302.h>
#define uchar unsigned char
#define uint unsigned int
sbit key1=P2^3; //獨立鍵盤的各個位置
sbit key2=P2^4;
sbit key3=P2^5;
sbit key4=P2^6;
sbit clock=P3^6; //是單片機上IO的位置
sbit dout=P3^7; //是out對應的位置
uchar wei[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //位選
uchar duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00}; //段選 0到9
uchar cun[8]; //每位數(shù)據存放的數(shù)組
uchar a;
void mode_change();
void chushi();
void dis_clock_time();
uchar read();
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void display() //顯示函數(shù)的固定格式 其中i和wei的取值根據自己的需要增加和減少
{
uint i;
for(i=0;i<8;i++) //兩位數(shù)的循環(huán) 兩取決于i
{
P1=0xff; //消影
switch(i)
{
case 0:P0=wei[0];break; //選擇第幾位
case 1:P0=wei[1];break;
case 2:P0=wei[2];break;
case 3:P0=wei[3];break;
case 4:P0=wei[4];break;
case 5:P0=wei[5];break;
case 6:P0=wei[6];break;
case 7:P0=wei[7];break;
}
P1=cun[i]; //存放第幾位
delay(1);
}
}
void main()
{
Ds1302Init();
chushi();
while(1)
{
a=read();
Ds1302ReadTime();
mode_change();
display();
}
}
void mode_change()
{
if(key1 == 0) //獨立鍵盤的固定格式
{
while(!key1)
{
cun[0]=~duan[TIME[5]%16]; //年
cun[1]=~duan[TIME[5]/16];
cun[2]=~duan[TIME[6]/16];
cun[3]=~duan[TIME[6]%16]&0x7f;
cun[4]=~duan[TIME[4]/16]; //月
cun[5]=~duan[TIME[4]%16]&0x7f;
cun[6]=~duan[TIME[3]/16];
cun[7]=~duan[TIME[3]%16]; //日
display(); //這個可以根據自己的需要而定,即鍵盤的作用
}
}
}
void chushi()
{
cun[0]=~duan[10];
cun[1]=~duan[10];
cun[2]=~duan[10];
cun[3]=~duan[10];
cun[4]=~duan[10];
cun[5]=~duan[10];
cun[6]=~duan[10];
cun[7]=~duan[10];
}
void dis_clock_time() //時鐘顯示
{
Ds1302ReadTime();
cun[0]=~duan[TIME[2]/16]; //小時
cun[1]=~duan[TIME[2]%16];
//閃爍 在中斷里面
cun[2]=~duan[TIME[1]/16]; //分鐘
cun[3]=~duan[TIME[1]%16];
cun[4]=~duan[10]; //“-”
cun[5]=~duan[a/100]; //ad顯示
cun[6]=~duan[a/10%10];
cun[7]=~duan[a%10];
display();
}
uchar read() //AD固定格式
{
uint i;
uchar ad=0x00;
dout=1;
for(i=0;i<8;i++)
{
ad=ad<<1; //左移的數(shù)碼管的 方便顯示各個位置的
if(dout)
{
ad++;
}
clock=1;
clock=0;
_nop_(); //相當于延遲函數(shù)delay
_nop_();
}
return ad;
}
復制代碼
所有資料51hei提供下載:
自動窗簾.rar
(33.99 KB, 下載次數(shù): 13)
2019-3-29 16:02 上傳
點擊文件名下載附件
自動窗簾
下載積分: 黑幣 -5
作者:
admin
時間:
2019-3-31 02:36
本帖需要重新編輯補全電路原理圖,源碼,詳細說明與圖片即可獲得100+黑幣(帖子下方有編輯按鈕)
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1