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

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

QQ登錄

只需一步,快速開(kāi)始

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

STC11F02E單鍵控制模式之折騰二

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:72519 發(fā)表于 2015-1-23 00:54 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
OMG!這樣操作是不可行的!用長(zhǎng)短按太讓人惱火,采用選擇狀態(tài)后計(jì)時(shí)4秒自動(dòng)切入;
本人一下子進(jìn)不了狀態(tài),在網(wǎng)上下了個(gè)PADS9.3瘋狂安裝,結(jié)果還是DEMO版本,又看了會(huì)兒片,洗完澡出來(lái)看代碼了;
呵呵呵,一下子明白過(guò)來(lái)了, 洗完衣服,來(lái)寫日志,把原先寫的程序又啃了遍,又對(duì)了下真值表,把原先打算不要的那部份又修改正確了!呵呵!明天再繼續(xù)。。。。。。
其實(shí)我也是在論壇上看了很多貼子,有的也是在別人的空間里看到的;相對(duì)來(lái)說(shuō),我就是個(gè)流浪漢。。。。。
  1. //#pragma src(signle.a51)

  2. #include <reg52.h>
  3. #include <display.c>
  4. #define uchar unsigned char
  5. #define uint unsigned int

  6. //sfr PCON = 0x87h;
  7. sbit Key1 = P3^2;
  8. sbit BUZ = P3^1;

  9. sbit Signle = P3^0;
  10. sbit Led0  = P1^0;
  11. sbit JDQ  = P1^2;
  12. sbit Dp = P1^5;
  13. sbit SMG1 = P3^7;
  14. sbit SMG2 = P3^5;
  15. sbit SMG3 = P3^4;
  16. sbit SMG4 = P3^3;
  17. uint Key_count,Time_value,Time_Count,BTime_Count;
  18. uchar Beep_time,Key_flag,BTime_Flag,JDQ_flag,BP_Count,LM_Count,LM_GroupCNT;
  19. uchar BT_Sec,Sec,Min,Hour,Key_Select,Key_long_flag,Key_long_count;
  20. uchar Led_Scan,Led_Loop,Sec_1,Min_1,Hour_1,BT_Sec_1;
  21. uchar Key_Select_Flag;
  22. //uchar Display_number[]={0xd7,0x14,0xcd,0x5d,0x1e,0x5b,0xdb,0x15,0xdf,0x5f,0x00};
  23. uchar code Display_number[]={0x28,0xeb,0x32,0xa2,0xe1,0xa4,0x24,0xea,0x20,0xa0,0xff,0xf7}; //0123456789 -
  24. uchar code Display_string[]={0xff,0xff,0xff,0xf7,0xeb,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-1HZ-
  25. uchar code Display_string2[]={0xff,0xff,0xff,0xf7,0x32,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-2HZ-
  26. uchar Clock[]={0xff,0xff,0xff,0xeb,0x32,0xf7,0xeb,0x32,0xf7,0xeb,0x32,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
  27. //---------------------------------------------------
  28. //---------------------------------------------------
  29. //4COM 共陽(yáng)數(shù)碼管 1234 SR410361K
  30. //---------------------------------------------------
  31. //P1.0 A;    |---|
  32. //P1.2 B;    |   |
  33. //P1.4 C;    |---|
  34. //P1.6 D;    |   |
  35. //P1.7 E;    |---|
  36. //P1.1 F;
  37. //P1.3 G;
  38. //P1.5 Dp;
  39. //SMG1=P3.7,SMG2=P3.5,SMG3=P3.4,SMG4=P3.3;
  40. //---------------------------------------------------
  41. //---------------------------------------------------
  42. void display_Scan(void);
  43. void Delay_ms();
  44. void Delay_ms(uint Tms)
  45. {
  46.   uint i,j;
  47.   for(i=Tms;i>0;i--)
  48.   for(j=1220;j>0;j--)
  49.   {;}
  50. }
  51. void Delay_us(uint Tus)
  52. {
  53.   while(--Tus);
  54. }
  55. void Buz(void)
  56.   {
  57.     uint i;
  58.     for(i=0;i<200;i++)
  59.     {
  60.       BUZ=~BUZ;
  61.      Delay_us(300);
  62.     }
  63.     BUZ=0;
  64.   }
  65. void Beep_Bi(void)
  66. {
  67.   if(Beep_time!=0)
  68.   {
  69.    Beep_time--;
  70.    BUZ=~BUZ;
  71.   }
  72.   else
  73.   {
  74.    BUZ=0;
  75.   }
  76. }
  77. void T0_ini()
  78. {
  79.    TMOD=0x12;
  80.   TH1=(65536-1000)/256;
  81.   TL1=(65536-1000)%256;
  82.   TR1=1;
  83.   ET1=1;
  84.   TH0=6;
  85.   TL0=6;
  86.   TR0=0;
  87.   ET0=1;
  88.   EA=1;
  89. }
  90. void TM0(void)interrupt 1
  91. {
  92.   //uint Time_Count,BTime_Count;
  93.   TF0=0;
  94.   Time_Count++;BTime_Count++;BP_Count++;
  95.   if(BTime_Count==2000)
  96.   {
  97.    BTime_Count=0;BT_Sec++;BTime_Flag=~BTime_Flag;
  98.   }
  99.   if(BP_Count==2)      //1ms DiDa Batime;
  100.   {
  101.    BP_Count=0;
  102.    Beep_Bi();
  103.   }
  104.   if(Key_Select_Flag==1)   //1Hz
  105.   {
  106.     if(Time_Count==2000)
  107.    {
  108.      Time_Count=0;Dp=~Dp;Signle=~Signle;
  109.    }
  110.   }
  111.   if(Key_Select_Flag==2)   //2Hz
  112.   {
  113.    if(Time_Count==1000)
  114.    {
  115.     Time_Count=0;Dp=~Dp;Signle=~Signle;
  116.    }
  117.   }
  118.     //if(Time_Count==2000) // ext atxl 12MHz;500ms
  119.   //if(Time_Count==1333) // ext atxl 8MHz 500ms;
  120.   //if(Time_Count==998) // built in atxl; 500ms
  121.   if(BT_Sec==2)
  122.   {
  123.    BT_Sec=0;
  124.    Sec++;
  125.    if(Sec==60)
  126.    {
  127.     Sec=0;Min++;
  128.    }
  129.      if(Min==60)        
  130.    {
  131.     Min=0;Hour++;
  132.    }
  133.    if(Hour==24)
  134.    {
  135.     Hour=0;
  136.    }
  137.   }
  138. }
  139. void TM1(void)interrupt 3
  140. {
  141.   TH1=(65536-1000)/256;
  142.   TL1=(65536-1000)%256;
  143.   Led_Scan=1;Led_Loop++;Led_Loop=Led_Loop&0x03;
  144.   
  145.     Key1=1;
  146.     if(Key1==0)
  147.     {
  148.      Key_count++;
  149.    if(Key_count==20)
  150.    {
  151.      Beep_time=100;
  152.      Key_flag=1;
  153.      TR0=1;
  154.      Key_Select++;
  155.      if(Key_Select==3)
  156.      {
  157.       Key_Select=0;Key_flag=0;TR0=1;
  158.      }
  159.        if(Key_Select==1)
  160.      {
  161.     Key_Select_Flag=1;
  162.      }
  163.     if(Key_Select==2)
  164.      {
  165.     Key_Select_Flag=2;
  166.         }   
  167.    }
  168.   }
  169.      else
  170.    {Key_count=0;Key_long_flag=0;Key_Select_Flag=0;}
  171.    }
  172.   void SmgDisp(uchar ch,uchar num)
  173.   {
  174.   uchar number;
  175.   number=num;
  176.   //P3=0x03;
  177.   P1=0xff;
  178.   SMG1=0;SMG2=0;SMG3=0;SMG4=0;
  179.   switch(ch)
  180.   {
  181.    case 1:SMG4=1;LM_Count=0;break;    //SMG排列 1 2 3 4 第四個(gè)數(shù)碼管
  182.    case 2:SMG3=1;LM_Count++;break;    //SMG排列 1 2 3 4 第三個(gè)數(shù)碼管
  183.    case 3:SMG2=1;LM_Count++;break;    //SMG排列 1 2 3 4 第二個(gè)數(shù)碼管
  184.    case 4:SMG1=1;LM_Count++;break;    //SMG排列 1 2 3 4 第一個(gè)數(shù)碼管
  185.    default:break;
  186.   }
  187.   if((Key_Select==0)&(Key_Select_Flag==1))
  188.   {
  189.    P1=Display_string[number];
  190.   }
  191.   if((Key_Select==0)&(Key_Select_Flag==2))
  192.   {
  193.    P1=Display_string2[number];
  194.   }
  195.   else
  196.    P1=Display_number[number];
  197.   }
  198.   void CheckTime()
  199.   {
  200.   if(Led_Scan)
  201.   {
  202.    switch(Led_Loop)
  203.    {
  204.     case 0:SmgDisp(4,LM_Count+LM_GroupCNT);break; //第一個(gè)數(shù)碼管
  205.     case 1:SmgDisp(3,LM_Count+LM_GroupCNT);break; //第二個(gè)數(shù)碼管
  206.     case 2:SmgDisp(2,LM_Count+LM_GroupCNT);break; //第三個(gè)數(shù)碼管
  207.     case 3:SmgDisp(1,LM_Count+LM_GroupCNT);break; //第四個(gè)數(shù)碼管
  208.    }
  209.      Led_Scan=0;
  210.   }
  211.   }
  212.   
  213. void Display(void)
  214. {
  215.   if((BTime_Flag)&(Key_Select==2))
  216.    {
  217.    P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0;
  218.              //P3=0x00;
  219.   }
  220.   else
  221.   {
  222.    if(BTime_Flag)
  223.   {
  224.    Dp=0;SMG1=1;       //P3=0x80;
  225.    Delay_ms(1);SMG1=0;      //P3=0x00;
  226.    Dp=0;SMG2=1;       //P3=0x20;
  227.    Delay_ms(1);SMG2=0;      //P3=0x00;
  228.   }
  229.   P1=Display_string[4];
  230.    SMG1=1;          //P3=0x80;
  231.   Delay_ms(1);
  232.    SMG1=0;          //P3=0x00;
  233.    P1=0xff;
  234.   P1=Display_string[5];
  235.    SMG2=1;          //P3=0x20;
  236.    Delay_ms(1);
  237.    SMG2=0;          //P3=0x00;
  238.    P1=0xff;
  239.   }
  240.   if((BTime_Flag)&(Key_Select==1))
  241.    {
  242.    P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0; //P3=0x00;
  243.   }
  244.   else
  245.   {
  246.    if(BTime_Flag)
  247.   {
  248.    Dp=0;SMG3=1;       //P3=0x10;
  249.    Delay_ms(1);SMG3=0;      //P3=0x00;
  250.    Dp=0;SMG4=1;       //P3=0x08;
  251.    Delay_ms(1);SMG4=0;      //P3=0x00;
  252.   }
  253.   P1=Display_string2[4];
  254.    SMG3=1;          //P3=0x10;
  255.    Delay_ms(1);
  256.    SMG3=0;          //P3=0x00;
  257.   P1=0xff;
  258.   P1=Display_string2[5];
  259.    SMG4=1;          //P3=0x08;
  260.    Delay_ms(1);
  261.    SMG4=0;          //P3=0x00;
  262.    P1=0xff;
  263.   }
  264. }
  265. void exint0(void)interrupt 0
  266. {
  267.   Buz();T0_ini();EX0=0;EA=1;
  268. }
  269.   
  270. void Display_Scan(void)
  271. {  
  272.   P1=0x00;
  273.   P3=0x00;
  274. //---------"A"--------------p1.0
  275.   //P1=0x01;
  276.   P1=0xfe;
  277.   P3=0x80;   //smg1
  278.   Delay_ms(5);
  279.   P1=0xff;
  280.   P3=0x00;
  281.   P1=0xfe;
  282.   P3=0x20;   //smg2
  283.   Delay_ms(5);
  284.   P1=0xff;
  285.   P3=0x00;
  286.   P1=0xfe;
  287.   P3=0x10;   //smg3
  288.   Delay_ms(5);
  289.   P1=0xff;
  290.   P3=0x00;
  291.   P1=0xfe;
  292.   P3=0x08;   //smg4
  293.   Delay_ms(5);
  294.   P1=0xff;
  295.   P3=0x00;
  296.   P1=0xfe;
  297.   P3=0x40;
  298.   Delay_ms(250);
  299. //---------"B"--------------p1.2
  300.   P1=0xfb;
  301.   P3=0x80;
  302.   Delay_ms(5);
  303.   P1=0xff;
  304.   P3=0x00;
  305.   P1=0xfb;
  306.   P3=0x20;
  307.   Delay_ms(5);
  308.   P1=0xff;
  309.   P3=0x00;
  310.   P1=0xfb;
  311.   P3=0x10;
  312.   Delay_ms(5);
  313.   P1=0xff;
  314.   P3=0x00;
  315.   P1=0xfb;
  316.   P3=0x08;
  317.   Delay_ms(5);
  318.   P1=0xff;
  319.   P3=0x00;
  320.   P1=0xfb;
  321.   P3=0x40;
  322.   Delay_ms(250);
  323. //---------"C"--------------p1.4
  324.   //P1=0x10;
  325.   P1=0xef;
  326.   P3=0x80;
  327.   Delay_ms(5);
  328.   P1=0xff;
  329.   P3=0x00;
  330.   P1=0xef;
  331.   P3=0x20;
  332.   Delay_ms(5);
  333.   P1=0xff;
  334.   P3=0x00;
  335.   P1=0xef;
  336.   P3=0x10;
  337.   Delay_ms(5);
  338.   P1=0xff;
  339.   P3=0x00;
  340.   P1=0xef;
  341.   P3=0x08;
  342.   Delay_ms(5);
  343.   P1=0xff;
  344.   P3=0x00;
  345.   P1=0xef;
  346.   P3=0x40;
  347.   Delay_ms(250);
  348. //---------"D"--------------p1.6
  349. //-----p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0---//
  350. //-------1011 1111-------------------------------//
  351.   P1=0xbf;
  352.   P3=0x80;
  353.   Delay_ms(5);
  354.   P1=0xff;
  355.   P3=0x00;
  356.   P1=0xbf;
  357.   P3=0x20;
  358.   Delay_ms(5);
  359.   P1=0xff;
  360.   P3=0x00;
  361.   P1=0xbf;
  362.   P3=0x10;
  363.   Delay_ms(5);
  364.   P1=0xff;
  365.   P3=0x00;
  366.   P1=0xbf;
  367.   P3=0x08;
  368.   Delay_ms(5);
  369.   P1=0xff;
  370.   P3=0x00;
  371.   P1=0xbf;
  372.   P3=0x40;
  373.   Delay_ms(250);
  374. //---------"E"--------------p1.7
  375.   P1=0x7f;
  376.   P3=0x80;
  377.   Delay_ms(5);
  378.   P1=0xff;
  379.   P3=0x00;
  380.   P1=0x7f;
  381.   P3=0x20;
  382.   Delay_ms(5);
  383.   P1=0xff;
  384.   P3=0x00;
  385.   P1=0x7f;
  386.   P3=0x10;
  387.   Delay_ms(5);
  388.   P1=0xff;
  389.   P3=0x00;
  390.   P1=0x7f;
  391.   P3=0x08;
  392.   Delay_ms(5);
  393.   P1=0xff;
  394.   P3=0x00;
  395.   P1=0x7f;
  396.   P3=0x40;
  397.   Delay_ms(250);
  398. //---------"F"--------------p1.1
  399.   P1=0xfd;
  400.   P3=0x80;
  401.   Delay_ms(5);
  402.   P1=0xff;
  403.   P3=0x00;
  404.   P1=0xfd;
  405.   P3=0x20;
  406.   Delay_ms(5);
  407.   P1=0xff;
  408.   P3=0x00;
  409.   P1=0xfd;
  410.   P3=0x10;
  411.   Delay_ms(5);
  412.   P1=0xff;
  413.   P3=0x00;
  414.   P1=0xfd;
  415.   P3=0x08;
  416.   Delay_ms(5);
  417.   P1=0xff;
  418.   P3=0x00;
  419.   P1=0xfd;
  420.   P3=0x40;
  421.   Delay_ms(250);
  422. //---------"G"--------------p1.3
  423.   P1=0xf7;
  424.   P3=0x80;
  425.   Delay_ms(5);
  426.   P1=0xff;
  427.   P3=0x00;
  428.   P1=0xf7;
  429.   P3=0x20;
  430.   Delay_ms(5);
  431.   P1=0xff;
  432.   P3=0x00;
  433.   P1=0xf7;
  434.   P3=0x10;
  435.   Delay_ms(5);
  436.   P1=0xff;
  437.   P3=0x00;
  438.   P1=0xf7;
  439.   P3=0x08;
  440.   Delay_ms(5);
  441.   P1=0xff;
  442.   P3=0x00;
  443.   P1=0xf7;
  444.   P3=0x40;
  445. //------------------------------
  446.   P1=0x00;
  447.   P3=0xfc;
  448.   Delay_ms(500);
  449. //------------------------------
  450.   P1=0x00;
  451.   P3=0x80;
  452.   Delay_ms(100);   //smg1
  453.   P1=0x00;
  454.   P3=0x20;
  455.   Delay_ms(100); //smg2
  456.   P1=0x00;
  457.   P3=0x10;
  458.   Delay_ms(100); //smg3
  459.   P1=0x00;
  460.   P3=0x08;  //smg4
  461.   Delay_ms(100);
  462.   P1=0x00;
  463.   P3=0xfc;
  464.   Delay_ms(250);
  465.   P1=0xff;
  466.   P3=0x00;
  467.   Delay_ms(250);
  468.   P1=0x00;
  469.   P3=0xfc;
  470.   Delay_ms(250);
  471. }
  472. void main(void)
  473. {
  474.    uint k;
  475.   Buz();Display_Scan();                                                                           
  476.    T0_ini();
  477.    while(1)
  478.    {
  479. ///*/-------------按鍵小于2次有分鐘睡眠模式-----------------
  480.    if(Hour==4)
  481.    {
  482.     EX0=1;
  483.     EA=1;
  484.     Key_flag=0;
  485.     Min_1=0;
  486.     Hour_1=0;                     
  487.     Signle=1;
  488.     TR0=1;
  489.     P1=0xff;
  490.     PCON=0x02;
  491.    }
  492. ////---------------------------------------------------------   */
  493.    if(Key_Select==0)
  494.    {  
  495.      //for(LM_GroupCNT=0;LM_GroupCNT<13;LM_GroupCNT++)//拉幕時(shí)鐘時(shí)分秒顯示
  496.     for(LM_GroupCNT=0;LM_GroupCNT<10;LM_GroupCNT++)
  497.     {
  498.      for(k=65500;k>0;k--)
  499.      {
  500.       CheckTime();
  501.      }
  502.     }
  503.    }
  504.    else
  505.    Display();
  506.    }
  507. }
復(fù)制代碼



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

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲高清成人在线 | 国产精品久久久久久吹潮 | 亚洲精久| 久久99精品久久久久久国产越南 | 欧美视频在线免费 | 一级片免费在线观看 | 国色天香成人网 | 一级黄色日本片 | 亚洲视频免费观看 | 欧美激情一区二区三级高清视频 | 在线观看av不卡 | 国产精品视频在线观看 | 国产精品中文字幕在线观看 | 久久久爽爽爽美女图片 | 久久国产精品免费 | 日日操操| 亚洲天堂精品久久 | 97国产精品视频人人做人人爱 | 欧美中文字幕一区二区三区 | 九九热精品在线 | 日韩一区在线播放 | 奇色影视| 一区二区国产在线观看 | 国产一区在线免费观看视频 | 精品乱码一区二区 | 亚洲精品欧美 | 午夜久久久久久久久久一区二区 | 中文字幕亚洲欧美日韩在线不卡 | 亚洲天堂成人在线视频 | 成人免费在线 | 91大神新作在线观看 | 国产精品国产a级 | 国产亚洲精品美女久久久久久久久久 | 成人毛片视频免费 | 欧美一二三区 | 拍拍无遮挡人做人爱视频免费观看 | 一级做a爰片性色毛片视频停止 | 黄色网毛片 | 色综合一区二区 | 嫩草一区二区三区 | 欧美综合一区二区 |