久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2249|回復(fù): 3
打印 上一主題 下一主題
收起左側(cè)

YL-236試驗臺 題目《產(chǎn)品包裝控制》

[復(fù)制鏈接]
回帖獎勵 15 黑幣 回復(fù)本帖可獲得 5 黑幣獎勵! 每人限 1 次
跳轉(zhuǎn)到指定樓層
樓主
ID:272089 發(fā)表于 2018-10-28 08:16 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
  1. #include<reg51.h>
  2. #include<intrins.h>

  3. #define uchar unsigned char
  4. #define uint  unsigned int

  5. void delay(uint i){while(i--);}

  6. sbit cs1=P2^0; sbit cs2=P2^1;sbit en=P2^2;sbit rw=P2^3;
  7. sbit rs=P2^4;  sbit wr=P2^5; sbit LED=P2^6; sbit f=P2^7;

  8. sbit wl1=P1^0;sbit wl2=P1^1;sbit wl3=P1^2;sbit wl4=P1^3;
  9. sbit wl5=P1^4;sbit wl6=P1^5;sbit wl7=P1^6;sbit col0=P1^7;


  10. sbit col1=P3^0;sbit col2=P3^1;sbit col3=P3^2;
  11. sbit w1=P3^3; sbit w2=P3^4;sbit w3=P3^5;
  12. sbit w4=P3^6;sbit w5=P3^7;

  13. sbit row0=P0^0;sbit row1=P0^1;sbit row2=P0^2;sbit row3=P0^3;

  14. #define zuo    {w1=0;w2=1;}
  15. #define you    {w1=1;w2=0;}
  16. #define stop   {w1=1;w2=1;}
  17. #define jia    {w3=0;w4=1;}
  18. #define song   {w3=1;w4=0;}
  19. #define shang  {w5=1;}
  20. #define xia    {w5=0;}

  21. uchar code ledcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
  22.                       0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x19,0x10,
  23.                                           0xbf,0xff};
  24. uchar buf[8];


  25. uchar code zm16x16l[]="產(chǎn)品手動包裝控制白黃色工作狀態(tài)左右移上升下降故障";
  26. uchar code zm16x16[][32]=
  27. {
  28. /*--  文字:  產(chǎn)  --*/
  29. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  30. 0x00,0x04,0xE4,0x44,0x4C,0x74,0x54,0x45,0x46,0x64,0x54,0x4C,0x44,0x64,0x44,0x00,
  31. 0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  32. /*--  文字:  品  --*/
  33. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  34. 0x00,0x00,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00,0x00,
  35. 0x00,0x7F,0x21,0x21,0x21,0x21,0x7F,0x00,0x7F,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,

  36. /*--  文字:  手  --*/
  37. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  38. 0x00,0x24,0x24,0x24,0x24,0x24,0x24,0xFE,0x22,0x22,0x22,0x22,0x22,0x20,0x00,0x00,
  39. 0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,

  40. /*--  文字:  動  --*/
  41. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  42. 0x20,0x24,0x24,0xE4,0x24,0x24,0x24,0x20,0x10,0x10,0xFF,0x10,0x10,0xF0,0x00,0x00,
  43. 0x08,0x1C,0x0B,0x08,0x0C,0x05,0x4E,0x24,0x10,0x0C,0x03,0x20,0x40,0x3F,0x00,0x00,

  44. /*--  文字:  包  --*/
  45. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  46. 0x80,0x40,0x20,0xD8,0x4F,0x4A,0x48,0x48,0x48,0xC8,0x08,0x08,0xFC,0x08,0x00,0x00,
  47. 0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x42,0x43,0x48,0x50,0x4F,0x40,0x70,0x00,

  48. /*--  文字:  裝  --*/
  49. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  50. 0x00,0x42,0x2C,0x24,0x10,0xFF,0x04,0x64,0xA4,0x24,0x3F,0x24,0x24,0x24,0x04,0x00,
  51. 0x20,0x21,0x11,0x11,0xF9,0x45,0x23,0x03,0x05,0x09,0x11,0x29,0x45,0xC1,0x41,0x00,

  52. /*--  文字:  控  --*/
  53. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  54. 0x08,0x08,0x08,0xFF,0x88,0x48,0x00,0x98,0x48,0x28,0x0A,0x2C,0x48,0xD8,0x08,0x00,
  55. 0x02,0x42,0x81,0x7F,0x00,0x00,0x40,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x40,0x00,

  56. /*--  文字:  制  --*/
  57. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  58. 0x00,0x50,0x4F,0x4A,0x48,0xFF,0x48,0x48,0x48,0x00,0xFC,0x00,0x00,0xFF,0x00,0x00,
  59. 0x00,0x00,0x3F,0x01,0x01,0xFF,0x21,0x61,0x3F,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,

  60. /*--  文字:  白  --*/
  61. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  62. 0x00,0x00,0xF8,0x08,0x08,0x0C,0x0B,0x08,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,0x00,
  63. 0x00,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,

  64. /*--  文字:  黃  --*/
  65. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  66. 0x20,0x24,0x24,0xA4,0xA4,0xBF,0xA4,0xE4,0xA4,0xBF,0xA4,0xA4,0x24,0x24,0x20,0x00,
  67. 0x00,0x80,0x80,0x5F,0x32,0x12,0x12,0x1F,0x12,0x12,0x32,0x5F,0xC0,0x00,0x00,0x00,

  68. /*--  文字:  色  --*/
  69. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  70. 0x00,0x40,0x20,0xF0,0x28,0x27,0x24,0xE4,0x24,0x34,0x2C,0xE4,0x00,0x00,0x00,0x00,
  71. 0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x43,0x42,0x42,0x42,0x43,0x40,0x78,0x00,0x00,

  72. /*--  文字:  工  --*/
  73. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  74. 0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,
  75. 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

  76. /*--  文字:  作  --*/
  77. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  78. 0x80,0x40,0x20,0xF8,0x07,0x22,0x18,0x0C,0xFB,0x48,0x48,0x48,0x68,0x48,0x08,0x00,
  79. 0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0xFF,0x04,0x04,0x04,0x04,0x06,0x04,0x00,

  80. /*--  文字:  狀  --*/
  81. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  82. 0x08,0x30,0x00,0xFF,0x20,0x20,0x20,0x20,0xFF,0x20,0xE1,0x26,0x2C,0x20,0x20,0x00,
  83. 0x04,0x02,0x01,0xFF,0x40,0x20,0x18,0x07,0x00,0x00,0x03,0x0C,0x30,0x60,0x20,0x00,

  84. /*--  文字:  態(tài)  --*/
  85. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  86. 0x00,0x04,0x04,0x04,0x84,0x44,0x34,0x4F,0x94,0x24,0x44,0x84,0x84,0x04,0x00,0x00,
  87. 0x00,0x60,0x39,0x01,0x00,0x3C,0x40,0x42,0x4C,0x40,0x40,0x70,0x04,0x09,0x31,0x00,

  88. /*--  文字:  左  --*/
  89. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  90. 0x08,0x08,0x08,0x08,0x08,0xC8,0x3F,0x0A,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
  91. 0x40,0x20,0x50,0x4C,0x43,0x41,0x41,0x41,0x7F,0x41,0x41,0x41,0x41,0x40,0x40,0x00,

  92. /*--  文字:  右  --*/
  93. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  94. 0x08,0x08,0x08,0x88,0xC8,0x38,0x0F,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
  95. 0x04,0x02,0x01,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,

  96. /*--  文字:  移  --*/
  97. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  98. 0x10,0x92,0x72,0xFE,0x91,0x19,0x90,0x88,0x44,0x53,0xA2,0x52,0x0A,0x06,0x00,0x00,
  99. 0x02,0x01,0x00,0xFF,0x00,0x81,0x88,0x44,0x46,0x29,0x11,0x09,0x05,0x03,0x01,0x00,

  100. /*--  文字:  上  --*/
  101. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  102. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00,
  103. 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x60,0x40,0x00,

  104. /*--  文字:  升  --*/
  105. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  106. 0x00,0x40,0x44,0x44,0x44,0xFE,0x42,0x42,0x40,0x40,0xFE,0x40,0x40,0x60,0x40,0x00,
  107. 0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,

  108. /*--  文字:  下  --*/
  109. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  110. 0x00,0x02,0x02,0x02,0x02,0x02,0x02,0xFE,0x22,0x62,0xC2,0x82,0x02,0x03,0x02,0x00,
  111. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,

  112. /*--  文字:  降  --*/
  113. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  114. 0x00,0xFE,0x22,0x5A,0x86,0x00,0x48,0x44,0x2B,0xD2,0x2A,0x26,0x42,0x40,0x40,0x00,
  115. 0x00,0xFF,0x02,0x04,0x03,0x00,0x0D,0x09,0x09,0xFF,0x09,0x09,0x09,0x08,0x00,0x00,

  116. /*--  文字:  故  --*/
  117. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  118. 0x10,0x90,0x90,0xFF,0x90,0x90,0x10,0x80,0xF0,0x1F,0x12,0x10,0xF0,0x10,0x10,0x00,
  119. 0x00,0x3F,0x10,0x10,0x10,0x5F,0x41,0x20,0x20,0x13,0x0C,0x13,0x20,0x60,0x20,0x00,

  120. /*--  文字:  障  --*/
  121. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  122. 0x00,0xFE,0x22,0x5A,0x86,0x10,0xD2,0x56,0x5A,0x53,0x52,0x5A,0xD6,0x12,0x10,0x00,
  123. 0x00,0xFF,0x02,0x04,0x13,0x10,0x17,0x15,0x15,0xFD,0x15,0x15,0x17,0x10,0x10,0x00,

  124. };


  125. uchar code zm8x16l[]="0123456789";
  126. uchar code zm8x16[][16]=
  127. {
  128. /*--  文字:  0  --*/
  129. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  130. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,

  131. /*--  文字:  1  --*/
  132. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  133. 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

  134. /*--  文字:  2  --*/
  135. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  136. 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,

  137. /*--  文字:  3  --*/
  138. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  139. 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,

  140. /*--  文字:  4  --*/
  141. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  142. 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,

  143. /*--  文字:  5  --*/
  144. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  145. 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,

  146. /*--  文字:  6  --*/
  147. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  148. 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,

  149. /*--  文字:  7  --*/
  150. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  151. 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,

  152. /*--  文字:  8  --*/
  153. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  154. 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,

  155. /*--  文字:  9  --*/
  156. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  157. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,
  158. };

  159. /*  鍵盤掃描 */
  160. uchar key()
  161. {
  162.     uchar k=25;
  163.     row0=0;  k=col0==0?0:col1==0?1:col2==0?2:col3==0?3:k;       row0=1;
  164.         row1=0;  k=col0==0?4:col1==0?5:col2==0?6:col3==0?7:k;       row1=1;
  165.         row2=0;  k=col0==0?8:col1==0?9:col2==0?10:col3==0?11:k;     row2=1;
  166.         row3=0;  k=col0==0?12:col1==0?13:col2==0?14:col3==0?15:k;   row3=1;
  167.         return k;
  168. }

  169. /*  寫命令  */
  170. void wc(uchar com)
  171. {
  172.     rs=0;rw=0;
  173.         P0=com;
  174.         en=1;en=0;
  175. }
  176. /*  寫數(shù)據(jù)     */
  177. void wd(uchar dat)
  178. {
  179.     rs=1;rw=0;
  180.         P0=dat;
  181.         en=1;en=0;
  182. }
  183. /* 清屏 */
  184. void clr()
  185. {
  186.     uchar i,j;
  187.         cs1=cs2=1;
  188.         for(i=0;i<8;i++)
  189.         {
  190.             wc(0xb8+i);
  191.                 wc(0x40);
  192.                 for(j=0;j<64;j++)wd(0);
  193.         }
  194. }
  195. /* 12864初始化 */
  196. void init()
  197. {
  198.    wc(0x3f);
  199.    wc(0xc0);
  200.    clr();
  201. }
  202. /* 顯示任意字模 */
  203. void showxy(uchar row,uchar col,uchar x,uchar y,uchar *tab)
  204. {
  205.     bit right;
  206.         uchar i,j;
  207.         if(col<64){right=0;}
  208.         else {col-=64;right=1;}
  209.         for(i=0;i<y;i++)
  210.         {
  211.             if(right)cs1=0,cs2=1;
  212.                 else cs1=1,cs2=0;
  213.                 wc(0xb8+row+i);
  214.                 wc(0x40+col);
  215.                 for(j=0;j<x;j++)
  216.                 {
  217.                     if(col+j<64)wd(tab[i*x+j]);
  218.                         else if(right==0)
  219.                         {
  220.                             cs1=0,cs2=1;
  221.                                 wc(0xb8+row+i);
  222.                                 wc(0x40+(col+j-64));
  223.                                 wd(tab[i*x+j]);
  224.                         }
  225.                 }
  226.         }
  227. }
  228. /*  8x16的索引 */
  229. uchar enn(uchar *s)
  230. {
  231.     uchar i;
  232.         for(i=0;zm8x16l[i]!=0;i++)if(zm8x16l[i]==s[0])break;
  233.         return i;
  234. }
  235. /*  16x16的索引 */
  236. uchar cnn(uchar *s)
  237. {
  238.     uchar i;
  239.         for(i=0;zm16x16l[i]!=0;i+=2)
  240.            if(zm16x16l[i]==*s&&zm16x16l[i+1]==*(s+1))break;
  241.         return i/2;
  242. }
  243. /*  顯示8x16及16x16的索引  */
  244. void showstr(uchar row,uchar col,uchar *s)
  245. {
  246.          uchar i;
  247.          for(i=0;s[i]!=0;i++)
  248.          {
  249.              if(s[i]<0x80)
  250.                  {
  251.                       showxy(row,col,8,2,zm8x16[enn(&s[i])]);
  252.                           col+=8;
  253.                  }
  254.                  else
  255.                  {
  256.                       showxy(row,col,16,2,zm16x16[cnn(&s[i])]);
  257.                           col+=16;i+=1;
  258.                  }
  259.                  if(col>120)
  260.                  {
  261.                       col=0;row+=2;
  262.                  }
  263.          }
  264. }
  265. /*  數(shù)碼管的驅(qū)動  */
  266. void dis()
  267. {
  268.     uchar i,j=0x7f;
  269.         for(i=0;i<8;i++)
  270.         {
  271.             cs1=0;cs2=1;
  272.                 P0=ledcode[buf[i]];wr=1;wr=0;
  273.                 cs1=1;cs2=0;
  274.                 P0=j;wr=1;wr=0;
  275.                 delay(40);
  276.                 j=(j>>1)|0x80;
  277.                 cs1=cs2=0;
  278.                 P0=0xff;wr=1;wr=0;
  279.         }
  280. }

  281. bit runflag=1,timeflag=1,timesz,keyflag,dian,stopflag=1;                  //運(yùn)行,時間,時間設(shè)置,按鍵,小數(shù)點(diǎn),停止的標(biāo)志
  282. uchar bs=0,hs=0,sec,min;                                                                                  //白色球,黃色球,秒,分的定義
  283. uchar n=0,moveflag,flag;                                                                      //n是機(jī)械手工步,moveflag是工作狀態(tài)標(biāo)志,flag夾球顏色判斷,


  284. void ka()                                                                                                   //鍵值和控制設(shè)置
  285. {
  286.         uchar i,k;
  287.         if(key()!=25&&keyflag==0)
  288.         {
  289.             keyflag=1;
  290.             if(key()==13&&runflag==1&&timeflag==1)
  291.                 {
  292.                     while(key()==13);
  293.                         bs++;                                                                                //白色球設(shè)置
  294.                         if(bs>10)bs=0;                                                                //到10就歸0
  295.                 }
  296.                 if(key()==14&&runflag==1&&timeflag==1)
  297.                 {
  298.                     while(key()==14);
  299.                         hs++;                                                                                 //黃色球設(shè)置
  300.                         if(hs>10)hs=0;                                                                 //到時就歸零
  301.                 }

  302.                 if(key()==12)timesz=1;                                                         //時間設(shè)置按鈕被按下

  303.                         if(key()<10&×z==1)                                                 //鍵盤值小于十
  304.                         {
  305.                            k=key();       
  306.                            for(i=0;i<7;i++)buf[i]=buf[i+1];                         //buf[7]顯示當(dāng)前數(shù)值,將之前的數(shù)值往前推
  307.                            buf[7]=k;
  308.                         }
  309.                             else if(key()==10&&dian==1)                                 //按鍵按下小數(shù)點(diǎn),并且沒有重復(fù)按下
  310.                                 {
  311.                                     dian=0;
  312.                                     buf[7]=buf[7]+10;                                         //將原來的數(shù)值加上十,就成為了有小數(shù)點(diǎn)的數(shù)
  313.                                 }
  314.                                    if(buf[7]<10)dian=1;

  315.                         min=buf[5]-10;                                                                 //分的取值
  316.                         sec=buf[6]*10+buf[7];                                                 //秒的取值


  317.                 if(key()==11&×z==1&&(bs!=0||hs!=0)&&(sec!=0||min!=0))                //按下運(yùn)行鍵,時間被設(shè)置完成,球的數(shù)量也被設(shè)置完成
  318.                 {
  319.                     runflag=0;                                                                                                        //運(yùn)行標(biāo)志變?yōu)?0 表示在運(yùn)行
  320.                         stopflag=1;                                                                                                        //停止標(biāo)志置 1
  321.                 }
  322.                 if(runflag==0&&key()==15)stopflag=0;                                                        //按下暫停鍵,停止標(biāo)志置 0
  323.                 if(stopflag==0){stop;runflag=1;}                                                                //停止,并且運(yùn)行鍵置 1
  324.         }
  325.                                                                                                                         //按鍵松開或沒有按下的標(biāo)志
  326.         if(key()==25)keyflag=0;
  327. }


  328. void jxs()                                                                                                   //機(jī)械手運(yùn)行函數(shù)
  329. {
  330.     switch(n)
  331.         {
  332.             case 0:
  333.                      if(wl5){xia;moveflag=4;break;}                                   //左移并顯示
  334.                          n=1;
  335.                 case 1:
  336.                      delay(20000);                                                                   //延時0.2秒等待機(jī)械手判斷
  337.                          n=2;
  338.                 case 2:
  339.                      if(wl7==0)flag=0;                                               //flag=0是黃色,白色相反
  340.                          else flag=1;
  341.                          n=3;
  342.                 case 3:
  343.                      if(wl6){jia;break;}                                                   //夾球
  344.                          n=4;
  345.                 case 4:
  346.                      if(wl6==0){n=5;break;}                                                   //夾緊就下一步
  347.                          else {moveflag=5;break;}                      //故障顯示
  348.                 case 5:
  349.                      if(wl4){shang;moveflag=3;break;}                           //上升并顯示
  350.                          n=6;
  351.                 case 6:
  352.                      if(wl3){zuo;moveflag=1;break;}                                   //左移并顯示
  353.                          stop;
  354.                          n=7;
  355.                 case 7:
  356.                      if(wl6==0){song;break;}                                           //松球
  357.                          if(flag==0)hs--;                                                           //減少黃球數(shù)
  358.                          else bs--;                                                                           //減少白球數(shù)
  359.                          n=8;
  360.                 case 8:
  361.                      if(wl1){you;moveflag=2;break;}                                   //右移并顯示
  362.                          stop;
  363.                          if(bs==0&&hs==0){runflag=1;moveflag=6;}           //運(yùn)球完成 開始包裝
  364.                          n=0;
  365.         }
  366. }  

  367. void init1()                                                                                          //初始化函數(shù)a
  368. {
  369.    TMOD=0x01;
  370.    EA=ET0=1;
  371.    init();
  372.    showstr(0,0,"產(chǎn)品手動包裝控制");                                                   //12864顯示
  373.    buf[0]=buf[1]=buf[2]=buf[3]=20;                                                   //顯示 ---------
  374.    buf[4]=buf[5]=buf[6]=buf[7]=20;
  375.    while(wl1)you;                                                                                   //機(jī)械手歸位
  376.    stop;                                                                                                   //移到一工位停止
  377.    song;                                                                                                   //松開爪子
  378.    delay(50000);                                                                                  
  379.    showstr(3,0,"白色");                                                                           //12864顯示
  380.    showstr(3,64,"黃色");
  381. }

  382. void main()                                                                                                   //主函數(shù)
  383. {                                                                                                                       
  384.    uchar z,x;                                                                                           //蜂鳴器及燈的閃爍
  385.    end:
  386.    init1();
  387.    while(1)
  388.    {
  389.         showxy(3,40,8,2,zm8x16[bs%10]);                                           //白球數(shù)量顯示
  390.                 showxy(3,104,8,2,zm8x16[hs%10]);                                   //黃球數(shù)量顯示

  391.                 ka();                                                                                          

  392.         if(runflag==0)                                                                           //系統(tǒng)運(yùn)行
  393.                 {                                                                                                   //定時器開
  394.                    TR0=1;                                                                                   //時間設(shè)置置 1
  395.                    timesz=1;                                                                           //機(jī)械手開啟
  396.                    jxs();                                                                                  
  397.                    buf[5]=min%10+10;                                                            //時間倒計時顯示
  398.                    buf[6]=sec/10%10;
  399.                    buf[7]=sec%10;

  400.                    /*   工作狀態(tài)顯示   */
  401.                    showstr(6,0,"工作狀態(tài)");
  402.                    if(moveflag==1)showstr(6,80,"左移");
  403.                    else if(moveflag==2)showstr(6,80,"右移");
  404.                    else if(moveflag==3)showstr(6,80,"上升");
  405.                    else if(moveflag==4)showstr(6,80,"下降");
  406.                    else if(moveflag==5)                                                                  //故障報警
  407.                    {
  408.                         showstr(6,80,"故障");                                                  //蜂鳴器以1秒五個周期報警
  409.                                 delay(10000);
  410.                             f=!f;
  411.                    }

  412.                    if(sec==0&&min==0){runflag=1;stop;}               //時間到就停止         
  413.                 }

  414.                 /*  抓球結(jié)束  */
  415.                 if(moveflag==6)                                                                                 //包裝  
  416.                 {
  417.                    showstr(6,80,"包裝");
  418.                    for(z=0;z<40;z++)                                                                 //循環(huán)二十秒
  419.                    {
  420.                        delay(25550);
  421.                            f=!f;                                                                                 //蜂鳴器一秒一周期
  422.                            for(x=0;x<2;x++)
  423.                            {
  424.                                delay(25550);
  425.                                    LED=!LED;                                                                 //LED0一秒兩周期
  426.                            }
  427.                    }
  428.                    moveflag=0;                                                                                 //完成所有操作回到初始化
  429.                    goto end;
  430.                 }
  431.                dis();
  432.    }
  433. }

  434. void time() interrupt 1                                                                                 //定時1
  435. {
  436.     TH0=0xfc;
  437.         TL0=0x17;
  438.         if(++c==1000)                                                                                          //運(yùn)行時分秒的運(yùn)行
  439.         {
  440.                c=0;
  441.                    sec--;
  442.                    if(sec==0&&min>0)
  443.                    {
  444.                         sec=60;
  445.                                 min--;
  446.                    }
  447.         }
  448. }
復(fù)制代碼


評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:88049 發(fā)表于 2019-5-28 18:43 | 只看該作者
厲害了
回復(fù)

使用道具 舉報

板凳
ID:523982 發(fā)表于 2022-12-5 22:31 | 只看該作者
不錯不錯,有任務(wù)書更好了
回復(fù)

使用道具 舉報

地板
ID:1127797 發(fā)表于 2024-7-2 01:26 | 只看該作者
可以做的不錯
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 台湾佬久久| 午夜影院黄 | 日本精品一区二区三区视频 | 自拍偷拍视频网 | 色橹橹欧美在线观看视频高清 | 日韩av在线免费 | 激情六月丁香婷婷 | 黄色在线免费看 | 国产精品福利在线 | 婷婷国产一区二区三区 | 日本精品裸体写真集在线观看 | 欧美成人一区二区 | 日韩中文在线视频 | 国产一级在线 | 天天爱爱网 | 国产不卡一区 | 91福利在线观看 | 成人福利视频网站 | 精品国产乱码久久久久久果冻传媒 | 99re在线视频免费观看 | 久久久久99 | 国产日韩欧美中文字幕 | 久久综合av| 国产精品乱码一区二区三区 | 蜜臀av日日欢夜夜爽一区 | 一区二区小视频 | 99久久中文字幕三级久久日本 | 96国产精品久久久久aⅴ四区 | 国产97在线视频 | www.久久 | 欧美a级成人淫片免费看 | 亚洲h视频| 综合久久av | 一区二区在线免费观看 | 日韩欧美一区二区三区 | 日韩欧美在线一区 | 国产精品美女久久久久久免费 | 中文字幕一区在线观看视频 | 国产精品一二区 | 亚洲人在线|