找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3955|回复: 1
打印 上一主题 下一主题
收起左侧

点阵16×16程序 74hc154+单片机驱动

[复制链接]
跳转到指定楼层
楼主
什么都不说,上资料

  1. #include <AT89X51.H>
  2. #include <intrins.h>
  3. #define uchar unsigned char
  4. #define uint unsigned int
  5. #define p0 P0
  6. #define p1 P1
  7. #define p2 P2
  8. #define p3 P3
  9. uchar taba[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
  10.               0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
  11. uchar tabc[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
  12. uchar tabb[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
  13. uchar tabd[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
  14. uchar a,b,c,d,e,f,g,h,i,j,k,l;
  15. void delaya();
  16. void delayb();
  17. void delayc();
  18. void delayd();
  19. void delaye();
  20. void delayf();
  21. void delayg();
  22. void delayh();
  23. void delayi();
  24. void delayj();
  25. void delay(unsigned int z)
  26. {
  27.         while(z--);
  28. }
  29. void main()
  30. {      
  31.    TMOD=0x11;
  32.    TH0=(65536-2000)/256;
  33.    TL0=(65536-2000)%256;
  34.    TH1=(65536-10000)/256;
  35.    TL1=(65536-10000)%256;
  36.    ET0=1;
  37.    TR0=1;
  38.    ET1=1;
  39.    TR1=1;
  40.    EA=1;
  41.         while(1)
  42.   {
  43.     delaya();
  44.     delayb();          
  45.     delayc();       
  46.     delayd();
  47.     delaye();
  48.     delayf();
  49.     delayg();
  50.     delayh();  
  51.     delayi();
  52. delayj();
  53.          }
  54.         }
  55. void li1() interrupt 1
  56. {
  57.    TH0=(65536-2000)/256;
  58.    TL0=(65536-2000)%256;
  59.         i++;
  60.         if(i==5) i=0;j++;
  61.         if(j==16) j=0;
  62.         }
  63. void li2() interrupt 3
  64. {
  65.    TH1=(65536-10000)/256;
  66.    TL1=(65536-10000)%256;
  67.    h++;
  68.         if(h==50) h=0;e++;l++;
  69.    if(e==8)  e=0;          
  70.    if(l==16) l=0;
  71.         }
  72. void delaya()
  73.    {
  74. for(c=0;c<3;c++)//下移
  75.   {        
  76.    p0=0xff;p1=0xff;
  77.    for(a=0;a<16;a++)
  78.           {
  79.           p2=taba[a];
  80.           delay(6000);
  81.           }       
  82.    }
  83. for(c=0;c<3;c++)//上移
  84.   {
  85.     p0=0xff;p1=0xff;       
  86.    for(a=0;a<16;a++)
  87.           {
  88.           p2=taba[15-a];
  89.           delay(6000);
  90.           }       
  91.    }
  92. for(c=0;c<3;c++)//上移和下移一起
  93.   {
  94.     p0=0xff;p1=0xff;       
  95.    for(a=0;a<16;a++)
  96.           {
  97.           p2=taba[16-a];
  98.           delay(4000);
  99.           p2=taba[a];
  100.           delay(4000);
  101.           }       
  102.    }
  103. for(a=0;a<200;a++)
  104.    {
  105.           p0=0x01;
  106.           p1=0x01;
  107.          for(b=0;b<=8;b++)
  108.          {
  109.                    p2=taba[15-j];
  110.                 p0=_crol_(p0,1);
  111.                 p1=_crol_(p0,1);
  112.            delay(200);
  113.                 }
  114.         }
  115. }
  116. void delayb()
  117.   {
  118.     for(a=0;a<8;a++)
  119.           {
  120.     for(g=0;g<16;g++)
  121.           {
  122.             p1=0x00;
  123.               p2=taba[g];  
  124.             p0=tabc[a];
  125.             delay(3000);
  126.                   }
  127.                     for(g=0;g<16;g++)
  128.                   {
  129.                  p2=taba[g];
  130.             p0=0x00;
  131.                  p1=tabc[a];
  132.        delay(3000);               
  133.       }
  134.          }
  135. for(a=0;a<200;a++)
  136.    {
  137.           p0=0x3f;
  138.           p1=0x3f;
  139.          for(b=0;b<=8;b++)
  140.          {
  141.                    p2=taba[j];
  142.                 p0=_crol_(p0,1);
  143.                 p1=_crol_(p0,1);
  144.            delay(200);
  145.                 }
  146.         }
  147.                  for(a=0;a<20;a++)//右移
  148.   {
  149.    for(c=0;c<=8;c++)
  150.         {
  151.     for(b=0;b<16;b++)
  152.          {
  153.     p2=taba[b];
  154.          delay(125);
  155.          }
  156.          p0=tabc[8-c];
  157.         p1=tabc[8-c];
  158.         delay(1000);
  159.    }
  160.         }
  161. }
  162. void delayc()
  163. {
  164.     for(a=0;a<2;a++)
  165.            {
  166.         for(g=0;g<=16;g++)
  167.                    {
  168.                          if(g<8)
  169.                          {
  170.                     p1=0x00;
  171.                       p2=taba[g];  
  172.                     p0=tabb[g];
  173.                     delay(4000);
  174.                          p2=taba[g];
  175.                     p0=0x00;
  176.                          p1=tabb[g];
  177.                delay(4000);
  178.                           }
  179.                        if(g>=8)
  180.                            {
  181.                          p1=0x00;
  182.                       p2=taba[g];  
  183.                     p0=tabb[g-8];
  184.                     delay(4000);
  185.                          p2=taba[g];
  186.                     p0=0x00;
  187.                          p1=tabb[g-8];
  188.                delay(4000);       
  189.                                 }
  190.                          }
  191.         }
  192. for(a=0;a<200;a++)
  193.    {
  194.           p0=0x01;
  195.           p1=0x01;
  196.          for(b=0;b<=8;b++)
  197.          {
  198.                    p2=taba[j];
  199.                 p0=_cror_(p0,1);
  200.                 p1=_cror_(p0,1);
  201.            delay(200);
  202.                 }
  203.         }
  204. for(f=0;f<2;f++)
  205.   {
  206. for(g=0;g<=16;g++)
  207.           {
  208.   if(g<8)
  209.            {
  210.                  p2=taba[g];
  211.             p1=0x00;
  212.                  p0=tabb[g];
  213.        delay(8000);
  214.            }
  215.           if(g>=8)
  216.            {
  217.                  p2=taba[g];
  218.                  p1=tabb[g-8];
  219.        delay(8000);       
  220.                 }  
  221.          }
  222.          }
  223.       for(b=0;b<80;b++)
  224.   {
  225.    for(a=0;a<15;a++)
  226.    {
  227.             p0=tabc[l];
  228.                 p1=tabc[l];
  229.                 p2=taba[j];
  230.                 delay(600);
  231.    }
  232.   }
  233. }
  234. void delayd()
  235. {          
  236. for(a=0;a<=8;a++)
  237.           {
  238.     for(g=0;g<=16;g++)
  239.           {
  240.             p1=0x00;
  241.               p2=taba[g];  
  242.             p0=tabb[a];
  243.             delay(2500);
  244.                  p2=taba[g];
  245.             p0=0x00;
  246.                  p1=tabb[a];
  247.        delay(2500);       
  248.                     }
  249.     }             
  250.   for(a=0;a<=8;a++)
  251.           {
  252.     for(g=0;g<=16;g++)
  253.           {
  254.             p1=0x00;
  255.               p2=taba[16-g];  
  256.             p0=tabb[a];
  257.             delay(2500);
  258.                  p2=taba[16-g];
  259.             p0=0x00;
  260.                  p1=tabb[a];
  261.        delay(2500);       
  262.                     }
  263.     }   
  264. for(b=0;b<120;b++)
  265.   {
  266.    for(a=0;a<15;a++)
  267.    {
  268.             p0=tabc[l];
  269.                 p1=tabc[l];
  270.                 p2=taba[j];
  271.                 delay(200);
  272.    }
  273.   }
  274. }
  275. void delaye()
  276. {
  277. for(a=0;a<20;a++)//左移
  278.   {
  279.    for(c=0;c<8;c++)
  280.         {
  281.     for(b=0;b<16;b++)
  282.          {
  283.     p2=taba[b];
  284.          delay(125);
  285.          }
  286.          p0=tabc[c];
  287.         p1=tabc[c];
  288.         delay(1000);
  289.    }
  290.         }
  291. for(c=0;c<3;c++)//上移和下移一起
  292.   { p0=0xff;p1=0xff;       
  293.    for(a=0;a<16;a++)
  294.           {
  295.           p2=taba[16-a];
  296.           delay(4000);
  297.           p2=taba[a];
  298.           delay(4000);
  299.           }       
  300.    }
  301. }
  302. void delayf()
  303. {
  304. for(a=0;a<=8;a++)
  305.           {
  306.    for(g=0;g<=16;g++)
  307.           {
  308.             p1=0x00;
  309.               p2=taba[16-g];  
  310.             p0=tabb[8-a];
  311.             delay(2500);
  312.                  p2=taba[16-g];
  313.             p0=0x00;
  314.                  p1=tabb[8-a];
  315.        delay(2500);       
  316.                     }   
  317.    }
  318.           for(b=0;b<80;b++)
  319.   {
  320.    for(a=0;a<15;a++)
  321.    {
  322.             p0=tabc[l];
  323.                 p1=tabc[l];
  324.                 p2=taba[j];
  325.                 delay(450);
  326.    }
  327.   }
  328. }
  329. void delayg()
  330. {
  331. for(b=0;b<120;b++)
  332.   {
  333.    for(a=0;a<15;a++)
  334.    {
  335.             p0=tabc[8-e];
  336.                 p1=tabc[8-e];
  337.                 p2=taba[15-j];
  338.                 delay(150);
  339.    }
  340.   }
  341. for(d=0;d<120;d++)
  342. {
  343.           p0=0x01;
  344.           p1=0x01;
  345.          for(b=0;b<=8;b++)
  346.          {
  347.                    p2=taba[15-j];
  348.                 p0=_crol_(p0,1);
  349.                 p1=_crol_(p0,1);
  350.            delay(200);
  351.                 }
  352.           p0=0x01;
  353.           p1=0x01;
  354.          for(b=0;b<=8;b++)
  355.          {
  356.                    p2=taba[j];
  357.                 p0=_crol_(p0,1);
  358.                 p1=_crol_(p0,1);
  359.            delay(200);
  360.         }
  361. }
  362. for(c=0;c<3;c++)//由中间向两边移动
  363.   {
  364.     p0=0xff;
  365.          p1=0xff;
  366.           for(a=8;a<16;a++)
  367.          {
  368.           p2=taba[a];
  369.           delay(4000);
  370.           p2=taba[16-a];
  371.           delay(4000);
  372.          }
  373.   }
  374. for(a=0;a<200;a++)
  375.    {
  376.           p0=0x3f;
  377.           p1=0x3f;
  378.          for(b=0;b<=8;b++)
  379.          {
  380.                    p2=taba[15-j];
  381.                 p0=_cror_(p0,1);
  382.                 p1=_cror_(p0,1);
  383.            delay(200);
  384.                 }
  385.         }
  386. for(b=0;b<80;b++)
  387.   {
  388.    for(a=0;a<15;a++)
  389.    {
  390.             p0=tabc[e];
  391.                 p1=tabc[e];
  392.                 p2=taba[j];
  393.                 delay(600);
  394.    }
  395.   }
  396. }
  397. void delayh()
  398. {
  399. for(a=0;a<2;a++)//左移
  400.   {
  401.     delay(65000);
  402.          for(c=0;c<=8;c++)
  403.         {
  404.     for(b=0;b<16;b++)
  405.          {
  406.     p2=taba[b];
  407.          delay(125);
  408.          }
  409.          p0=tabb[c];
  410.         p1=tabb[c];
  411.         delay(2000);                 
  412.         }
  413.   for(c=0;c<=8;c++)
  414.         {
  415.     for(b=0;b<16;b++)
  416.          {
  417.     p2=taba[b];
  418.          delay(125);
  419.          }
  420.          p0=tabd[c];
  421.          p1=tabd[c];
  422.          delay(800);          
  423.     }
  424.    }
  425. }
  426. void delayi()
  427. {
  428. for(d=0;d<120;d++)
  429. {
  430.           p0=0x01;
  431.           p1=0x01;
  432.          for(b=0;b<=8;b++)
  433.          {
  434.                    p2=taba[15-j];
  435.                 p0=_cror_(p0,1);
  436.                 p1=_cror_(p0,1);
  437.            delay(200);
  438.                 }
  439.           p0=0x01;
  440.           p1=0x01;
  441.          for(b=0;b<=8;b++)
  442.          {
  443.                    p2=taba[j];
  444.                 p0=_cror_(p0,1);
  445.                 p1=_cror_(p0,1);
  446.            delay(200);
  447.         }
  448. }
  449. for(a=0;a<200;a++)
  450.    {
  451.           p0=0x01;
  452.           p1=0x01;
  453.          for(b=0;b<=8;b++)
  454.          {
  455.                    p2=taba[j];
  456.                 p0=_crol_(p0,1);
  457.                 p1=_crol_(p0,1);
  458.            delay(200);
  459.                 }
  460.         }       
  461. for(a=0;a<200;a++)
  462.    {
  463.           p0=0x3f;
  464.           p1=0x3f;
  465.          for(b=0;b<=8;b++)
  466.          {
  467.                    p2=taba[j];
  468.                 p0=_cror_(p0,1);
  469.                 p1=_cror_(p0,1);
  470.            delay(200);
  471.                 }
  472.         }
  473. for(a=0;a<200;a++)
  474.    {
  475.           p0=0x01;
  476.           p1=0x01;
  477.          for(b=0;b<=8;b++)
  478.          {
  479.                    p2=taba[15-j];
  480.                 p0=_cror_(p0,1);
  481.                 p1=_cror_(p0,1);
  482.            delay(200);
  483.                 }
  484.         }
  485. for(b=0;b<80;b++)   //星光璀璨
  486.   {
  487.    for(a=0;a<15;a++)
  488.    {
  489.             p0=tabc[e];
  490.                 p1=tabc[e];
  491.                 p2=taba[j];
  492.                 delay(450);
  493.    }
  494.   }
  495. }
  496. void delayj()
  497. {

  498. for(a=0;a<200;a++)
  499.    {
  500.           p0=0x33;
  501.           p1=0x33;
  502.          for(b=0;b<=8;b++)
  503.          {
  504.                    p2=taba[j];
  505.                 p0=_crol_(p0,1);
  506.                 p1=_crol_(p0,1);
  507.            delay(200);
  508.                 }
  509.         }
  510. for(a=0;a<200;a++)
  511.    {
  512.           p0=0x33;
  513.           p1=0x33;
  514.          for(b=0;b<=8;b++)
  515.          {
  516.                    p2=taba[j];
  517.                 p0=_cror_(p0,1);
  518.                 p1=_cror_(p0,1);
  519.            delay(200);
  520.                 }
  521.         }
  522.         }
复制代码


小蛮腰.rar

7.24 MB, 下载次数: 44, 下载积分: 黑币 -5

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的积分奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:103996 发表于 2016-3-15 21:26 来自手机 | 只看该作者
谢谢分享,希望能用
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表