欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
樓主: hfuttcy
打印 上一主題 下一主題
收起左側(cè)

51單片機(jī)智能窗簾控制設(shè)計(jì)(源碼+AD畫的PCB與原理圖)

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
給51黑電子論壇的朋友們分享一個(gè)基于51單片機(jī)的智能窗簾控制系統(tǒng)(帶51單片機(jī)源碼+ad軟件畫的原理圖和pcb工程文件),這是我的畢業(yè)設(shè)計(jì),大家多多指教.

智能窗簾的原理圖(ad畫的 需要用ad打開):


智能窗簾的pcb工程文件:


單片機(jī)窗簾主程序:
  1. #include <reg51.h>//51頭文件
  2. #include<INTRINS.h>
  3. #define uchar unsigned char
  4. #define uint  unsigned int //變量宏定義
  5. #define ulong  unsigned long //變量宏定義
  6. uchar count,s1num,shi2=0,fen2=0,shi3=10,fen3=10;//全局變量
  7. uchar miao,fen,shi;//時(shí)間變量
  8. uchar c,v,l,i;

  9. ulong AD_ad1,AD_ad2;
  10. float JiZhun_AD=2.5;
  11. float AD_Data=0.0;
  12. ulong AD_ad=0;
  13. uchar dianji;

  14. sbit rs = P0^5;//數(shù)據(jù),命令選擇端(H/L)
  15. sbit rw = P0^6;//讀,寫選擇端(H/L)
  16. sbit e = P0^7;//使能信號(hào)

  17. sbit CLOCK = P1^1; //lcd
  18. sbit D_IN  = P1^2; //lcd
  19. sbit D_OUT = P1^3; //lcd
  20. sbit _CS   = P1^4; //lcd

  21. sbit menu = P1^0;  //按鍵//P1^3
  22. sbit add  = P1^7;  //按鍵//P1^4
  23. sbit cut  = P1^5;  //按鍵
  24. sbit yes  = P1^6;  //按鍵

  25. sbit   ma = P3^0; //步進(jìn)電機(jī)
  26. sbit   mb = P3^1; //步進(jìn)電機(jī)
  27. sbit   mc = P3^2; //步進(jìn)電機(jī)
  28. sbit   md = P3^3; //步進(jìn)電機(jī)
  29. sbit led1 = P3^4; //LED1
  30. sbit led2 = P3^5; //LED2
  31. sbit spek = P3^6; //SPEK

  32. uchar code  table[]="shut-00:00|ray:0";
  33. uchar code table1[]="open-00:00|00:00";//數(shù)據(jù)字符表
  34. uchar data display[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
  35. //顯示單元后臺(tái)數(shù)據(jù),1分2時(shí)現(xiàn)在時(shí)間,5分6時(shí)關(guān)閉時(shí)間,3分4時(shí)打開時(shí)間,7亮度級(jí)數(shù) //
  36. //****************延時(shí)*****************
  37. void delay(uint z)
  38. {
  39. uint x,y;
  40.   for(x=z;x>0;x--)
  41.    for(y=110;y>0;y--) ;
  42. }
  43. //****************寫液晶指令*****************
  44. void write_com(uchar com)
  45. {
  46. rs=0;
  47. e=0;
  48. P2=com;
  49. delay(5);
  50. e=1;
  51. delay(5);
  52. e=0;
  53. }
  54. //****************液晶數(shù)據(jù)*****************
  55. void write_date(uchar date)
  56. {
  57. rs=1;
  58. e=0;
  59. P2=date;
  60. delay(5);
  61. e=1;
  62. delay(5);
  63. e=0;
  64. }
  65. //****************初始化液晶定時(shí)器************
  66. void init() //
  67. {
  68. uchar num;
  69. rs=0;
  70. rw=0;
  71. e=0;//鎖存關(guān)閉
  72. write_com(0x38);
  73. delay(5);
  74. write_com(0x0c);//
  75. delay(5);
  76. write_com(0x06);
  77. delay(5);
  78. write_com(0x01);
  79. write_com(0x80);//第一行開始寫
  80.   for(num=0;num<16;num++)
  81.    {
  82.    write_date(table[num]);
  83.    delay(20);
  84.    }
  85.     write_com(0x80+0x40);//第二行前一部分,也就是時(shí)間開始寫
  86.    for(num=0;num<16;num++)
  87.    {
  88.      write_date(table1[num]);
  89.    delay(20);
  90.   }
  91. TMOD=0x01;//定時(shí)器0的方式1
  92. TH0=(65536-50000)/256;//求模
  93. TL0=(65536-50000)%256;//取余
  94. EA=1;//開總中斷
  95. ET0=1;//開定時(shí)器中斷
  96. TR0=1;//啟動(dòng)定時(shí)器
  97. }
  98. //****************地址數(shù)據(jù)變量**************
  99. void write_sfm(uchar add, uchar date)
  100. {
  101. uchar shi,ge;
  102. shi=date/10;
  103. ge=date%10;
  104. write_com(0x80+0x40+add);
  105. write_date(0x30+shi);
  106. write_date(0x30+ge);
  107. }
  108. void write_sfn(uchar add, uchar date)
  109. {
  110. uchar si,g;
  111. si=date/10;
  112. g=date%10;
  113. write_com(0x80+add);
  114. write_date(0x30+si);
  115. write_date(0x30+g);
  116. }

  117. //****************按鍵函數(shù)*****************
  118. void key()
  119. {  
  120.   if(c==8)c=0;
  121.   if(menu==0)
  122.                 {
  123.                 delay(50);
  124.                 if(menu==0)
  125.                         {
  126.                         c++;spek=0;delay(50);
  127.                         while(menu==0);spek=1;
  128.                         }
  129.                 }
  130.    if(add==0)
  131.                    {
  132.                    spek=0;delay(50);
  133.                 while(add==0);
  134.                    spek=1;
  135.                    display[c]++;
  136.                 write_sfm(14,display[1]);//分針位置
  137.                 write_sfm(11,display[2]);//時(shí)針位置
  138.                    }
  139.         if(cut==0)
  140.                 {
  141.                 spek=0;delay(50);
  142.                 while(cut==0);
  143.                 spek=1;
  144.                 display[c]--;
  145.                 }
  146.         if(yes==0)
  147.                 {
  148.                 spek=0;delay(50);
  149.                 while(yes==0);
  150.                 spek=1;
  151.                 c=0;
  152.                 }
  153.   write_sfm(14,display[1]);//現(xiàn)在分針位置
  154.   write_sfm(11,display[2]);//現(xiàn)在時(shí)針位置
  155.   write_sfm(8,display[3]);//打開分針位置
  156.   write_sfm(5,display[4]);//打開分針位置
  157.   write_sfn(8,display[5]);//關(guān)閉分針位置
  158.   write_sfn(5,display[6]);//關(guān)閉分針位置
  159.   write_com(0x80+15);          //亮度級(jí)數(shù)
  160.   write_date(0x30+display[7]);//亮度級(jí)數(shù)位置   
  161. }
  162. //****************步進(jìn)電機(jī)函數(shù)*****************
  163. void motorzen()
  164. {        
  165.    while(v)
  166.                 {
  167.                 led1=0;               
  168.                 ma=1,mb=0;mc=0;md=0;delay(3);
  169.                 ma=0,mb=1;mc=0;md=0;delay(3);
  170.                 ma=0,mb=0;mc=1;md=0;delay(3);
  171.                 ma=0,mb=0;mc=0;md=1;delay(3);
  172.                 }
  173.         led1=1;               
  174. }
  175. void motorfan()
  176. {        
  177.    while(v&l)
  178.                 {
  179.                 led2=0;               
  180.                 ma=0,mb=0;mc=0;md=1;delay(3);
  181.                 ma=0,mb=0;mc=1;md=0;delay(3);
  182.                 ma=0,mb=1;mc=0;md=0;delay(3);
  183.                 ma=1,mb=0;mc=0;md=0;delay(3);
  184.                 }
  185.                 led2=1;
  186. }

  187. //****************A/D*****************
  188. uint read1543(uchar port)
  189.         {        
  190.         uint ad;
  191.         uint i;
  192.         uchar al=0,ah=0;
  193.         CLOCK=0;
  194.         _CS=0;
  195.         port<<=4;
  196.         for (i=0;i<4;i++) //將四位通道地址送1543
  197.                 {
  198.                 D_IN=(bit)(port&0x80);CLOCK=1;CLOCK=0;
  199.                 port<<=1;
  200.                 }
  201.         for (i=0;i<6;i++) //填6個(gè)CLOCK信號(hào)
  202.                 {
  203.                 CLOCK=1;CLOCK=0;
  204.                 }
  205.         _CS=1;
  206.         _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  207.         _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  208.         _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  209.         _nop_();_nop_();_nop_();
  210.         _CS=0; //等待AD轉(zhuǎn)換結(jié)束
  211.         _nop_();_nop_();_nop_();
  212. for (i=0;i<2;i++) //D9,D8
  213.                 {        
  214.                 D_OUT=1;CLOCK=1;ah<<=1;               
  215.                 if (D_OUT) ah +=0x01;
  216.                 CLOCK=0;
  217.                 }
  218.         for (i=0;i<8;i++) //取出D7--D0
  219.                 {        
  220.                 D_OUT=1;CLOCK=1;al <<= 1;               
  221.                 if (D_OUT)
  222.                 al +=0x01;
  223.                 CLOCK=0;
  224.                 }
  225. _CS=1;        
  226. ad = (uint)ah;
  227. ad <<= 8;
  228. ad +=(uint)al; //
  229. return(ad);
  230. }

  231. //****************亮度測(cè)試*****************
  232. void liangdu()
  233. {
  234.         i++;
  235.         if(i==30)
  236.                  {
  237.                  i=0;
  238.                  AD_ad1 = read1543(0);   //          (通道0電壓正端)
  239.                  AD_Data = ((float)AD_ad1)*JiZhun_AD*2/1024+0.005;//0.15經(jīng)過實(shí)測(cè)需要加0.15減少誤差        
  240.                  AD_ad =(AD_Data*100);
  241.                  if(display[7]>AD_ad%100/10)
  242.                            {
  243.                          if(dianji==0)
  244.                                  {
  245.                                  spek=0;delay(50);spek=1;
  246.                                  motorzen();
  247.                                 dianji=1;
  248.                              }
  249.                             }
  250.                 else
  251.                            {
  252.                          if(dianji==1)
  253.                                  {
  254.                                  spek=0;delay(50);spek=1;
  255.                                  motorfan();
  256.                                 dianji=0;
  257.                             }
  258.                             }
  259.                 }
  260.   }
  261. //****************主函數(shù)*****************
  262. void main()
  263. {
  264. spek=0;delay(50);spek=1;
  265. display[4]=8;
  266. display[6]=20;
  267. display[7]=50;
  268. spek=1;
  269. init();
  270. while(1)
  271.    {
  272.    key();liangdu();
  273.         if(display[2]==display[4])//時(shí)間判斷關(guān)閉窗簾
  274.                 {
  275.                  if(display[1]==display[3])//與打開時(shí)間一致動(dòng)作
  276.                          {
  277.                                 if(miao<5)
  278.                                 {
  279.                                  v=10;
  280.                                  spek=0;delay(50);spek=1;
  281.                                  motorzen();
  282.                                 }
  283.                         }
  284.                 }
  285.         if(display[2]==display[6])//時(shí)間判斷關(guān)閉窗簾
  286.                 {
  287.                  if(display[1]==display[5])//與打開時(shí)間一致動(dòng)作
  288.                           {
  289.                                 if(miao<5)
  290.                                         {
  291.                                          v=10;
  292.                                          spek=0;delay(50);spek=1;
  293.                                          motorfan();
  294.                                         }
  295.                          }
  296.                 }
  297.    }
  298. }
  299.   
  300. void timer0() interrupt 1 //定時(shí)器0中斷服程序
  301. {
  302.     TH0=(65536-50000)/256;//求模
  303.     TL0=(65536-50000)%256;//求佘
  304.     count++;//變量
  305.   if(count==20)//此處為時(shí)間基準(zhǔn)調(diào)節(jié),20為走一秒


  306. …………余下代碼請(qǐng)下載附件…………
復(fù)制代碼


資料下載:
窗簾控制.rar (1.21 MB, 下載次數(shù): 502)

評(píng)分

參與人數(shù) 1黑幣 +1 收起 理由
Eleven_1ing + 1 很給力!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏21 分享淘帖 頂6 踩

相關(guān)帖子

回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:96326 發(fā)表于 2017-3-20 08:07 | 只看該作者
謝謝分享,51黑有你更精彩
回復(fù)

使用道具 舉報(bào)

板凳
ID:130231 發(fā)表于 2017-3-20 12:07 | 只看該作者
不錯(cuò)哦。感謝您的分享
回復(fù)

使用道具 舉報(bào)

地板
ID:82765 發(fā)表于 2017-3-20 15:22 | 只看該作者
謝謝分享,。,。
回復(fù)

使用道具 舉報(bào)

5#
ID:183120 發(fā)表于 2017-3-29 10:00 | 只看該作者
你好!請(qǐng)問你這個(gè)智能窗簾的模型能分享一下嗎?
回復(fù)

使用道具 舉報(bào)

6#
ID:183120 發(fā)表于 2017-3-29 10:01 | 只看該作者
你好!請(qǐng)問你這個(gè)智能窗簾的模型能分享一下嗎?
回復(fù)

使用道具 舉報(bào)

7#
ID:185352 發(fā)表于 2017-4-1 14:19 來自觸屏版 | 只看該作者
感謝樓主,樓主窗簾主要實(shí)現(xiàn)了哪些功能呢?
回復(fù)

使用道具 舉報(bào)

8#
ID:185671 發(fā)表于 2017-4-2 21:36 | 只看該作者
挺好很有用
回復(fù)

使用道具 舉報(bào)

9#
ID:185671 發(fā)表于 2017-4-2 21:36 | 只看該作者
試一試能下載
回復(fù)

使用道具 舉報(bào)

10#
ID:185946 發(fā)表于 2017-4-10 11:31 | 只看該作者
樓主 你好 有做好的仿真嗎?
回復(fù)

使用道具 舉報(bào)

11#
ID:192050 發(fā)表于 2017-4-21 16:45 | 只看該作者
bbxyzzj 發(fā)表于 2017-3-20 08:07
謝謝分享,51黑有你更精彩

回復(fù)

使用道具 舉報(bào)

12#
ID:192050 發(fā)表于 2017-4-21 18:57 | 只看該作者
頂一個(gè),好用哦
回復(fù)

使用道具 舉報(bào)

13#
ID:197714 發(fā)表于 2017-5-7 17:28 | 只看該作者
我也在做這個(gè)
回復(fù)

使用道具 舉報(bào)

14#
ID:170729 發(fā)表于 2017-5-7 19:53 | 只看該作者
很厲害,如果用32實(shí)現(xiàn)就更好了
回復(fù)

使用道具 舉報(bào)

15#
ID:245224 發(fā)表于 2017-11-2 11:52 | 只看該作者
不過,正好需要這個(gè),感謝有你
回復(fù)

使用道具 舉報(bào)

16#
ID:235860 發(fā)表于 2017-12-5 21:21 | 只看該作者
好人,得贊一下,謝謝啦
回復(fù)

使用道具 舉報(bào)

17#
ID:287609 發(fā)表于 2018-3-5 08:00 | 只看該作者
感謝大佬,好用
回復(fù)

使用道具 舉報(bào)

18#
ID:296795 發(fā)表于 2018-3-25 16:20 | 只看該作者
下不了啊
回復(fù)

使用道具 舉報(bào)

19#
ID:295949 發(fā)表于 2018-3-25 19:54 來自觸屏版 | 只看該作者
沒有裝置模型嗎
回復(fù)

使用道具 舉報(bào)

20#
ID:310038 發(fā)表于 2018-4-17 14:26 | 只看該作者
謝謝分享
回復(fù)

使用道具 舉報(bào)

21#
ID:310038 發(fā)表于 2018-4-18 09:34 | 只看該作者
謝謝分享,51黑有你更精彩
回復(fù)

使用道具 舉報(bào)

22#
ID:320322 發(fā)表于 2018-5-2 11:22 | 只看該作者
有參考價(jià)值
回復(fù)

使用道具 舉報(bào)

23#
ID:145504 發(fā)表于 2018-5-2 12:18 來自觸屏版 | 只看該作者
謝謝分享!
回復(fù)

使用道具 舉報(bào)

24#
ID:341413 發(fā)表于 2018-5-30 15:25 | 只看該作者
感謝有你
回復(fù)

使用道具 舉報(bào)

25#
ID:110278 發(fā)表于 2018-5-31 20:13 | 只看該作者
很不錯(cuò)的。
回復(fù)

使用道具 舉報(bào)

26#
ID:350853 發(fā)表于 2018-6-25 09:14 | 只看該作者
感謝分享!
回復(fù)

使用道具 舉報(bào)

27#
ID:369644 發(fā)表于 2018-7-11 17:48 | 只看該作者
剛好要做這個(gè)設(shè)計(jì),給力!
回復(fù)

使用道具 舉報(bào)

28#
ID:379452 發(fā)表于 2018-8-26 12:04 | 只看該作者
感謝分享,謝謝
回復(fù)

使用道具 舉報(bào)

29#
ID:391029 發(fā)表于 2018-9-1 06:55 | 只看該作者
正好需要,下載看看
回復(fù)

使用道具 舉報(bào)

30#
ID:388870 發(fā)表于 2018-9-10 16:25 | 只看該作者
謝謝分享
回復(fù)

使用道具 舉報(bào)

31#
ID:396551 發(fā)表于 2018-9-12 16:20 | 只看該作者
謝謝分享
回復(fù)

使用道具 舉報(bào)

32#
ID:104477 發(fā)表于 2018-9-15 17:27 來自觸屏版 | 只看該作者
帶屏幕是多此一舉,裝上放在窗簾上那么高什么都看不了
回復(fù)

使用道具 舉報(bào)

33#
ID:398464 發(fā)表于 2018-9-15 23:49 | 只看該作者
可以用proteus來仿真實(shí)現(xiàn)嗎
回復(fù)

使用道具 舉報(bào)

34#
ID:388834 發(fā)表于 2018-9-16 05:33 | 只看該作者
謝謝分享
回復(fù)

使用道具 舉報(bào)

35#
ID:510545 發(fā)表于 2019-4-12 15:35 | 只看該作者
樓主好人
回復(fù)

使用道具 舉報(bào)

36#
ID:375715 發(fā)表于 2019-4-28 03:21 來自觸屏版 | 只看該作者
謝謝分享
回復(fù)

使用道具 舉報(bào)

37#
ID:922571 發(fā)表于 2021-6-21 11:45 | 只看該作者
新人表示看不懂
回復(fù)

使用道具 舉報(bào)

38#
ID:941255 發(fā)表于 2021-6-22 08:40 | 只看該作者
無私奉獻(xiàn)者,給力!
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表