<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51和VB數(shù)字量簡(jiǎn)易測(cè)試

          51和VB數(shù)字量簡(jiǎn)易測(cè)試

          作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏

          //51代碼
          #include
          #define uchar unsigned char
          #define uint unsigned int
          void delay(uint k)
          {
          while(k--);
          }
          uchar rec;//接受到的數(shù)據(jù)
          sbit q1=P1^0; //輸出點(diǎn)
          sbit q2=P1^1; //輸出點(diǎn)
          sbit q3=P1^2; //輸出點(diǎn)
          sbit q4=P1^3; //輸出點(diǎn)
          sbit fk=P1^4; //反饋點(diǎn)
          sbit j1=P2^4;//反饋發(fā)光指示

          void light()
          {
          if(rec==1)q1=0;
          else if(rec==2)q2=0;
          else if(rec==3)q3=0;
          else if(rec==4)q4=0;
          else if(rec==5)q1=1;
          else if(rec==6)q2=1;
          else if(rec==7)q3=1;
          else if(rec==8)q4=1;
          }
          void serial_init() //串口初始化
          {
          SM2=0;
          SM1=1;
          SM0=0;
          TMOD|=0x20; //自動(dòng)重裝載
          TH1=TL1=253;
          TR1=1;
          REN=1;
          }
          void str_init()//串口中斷初始化
          {
          EA=1;
          ES=1;
          }
          void str_send(uchar u) //串口發(fā)送函數(shù)
          {
          bit es;
          es=ES; //保存現(xiàn)場(chǎng)
          ES=0;
          SBUF=u;
          while(TI==0);
          TI=0;
          ES=es;
          }
          void str_event() interrupt 4
          {
          if(RI)
          {
          rec=SBUF;
          RI=0;
          }
          else
          {
          ;
          }
          }

          void main()
          {
          serial_init();
          str_init();
          fk=0;
          while(1)
          {
          if(fk==1) //正常
          {
          str_send(9);
          j1=0;
          delay(400);
          }
          if(fk==0)
          {
          str_send(a); //故障
          j1=1;
          delay(400);
          }
          light();
          }
          }
          51單片機(jī)端口全部源碼可以
          從這里http://www.51hei.com/f/51vbcs.rar下載.
          //---------- VB代碼--------------------------------------------------------

          Private Sub Command1_Click()
          On Error GoTo errline:
          MSComm1.Output = "1"
          Shape1.FillColor = vbGreen
          Exit Sub
          errline:
          If Err.Number = 8018 Then
          Text3.Text = "串口已關(guān)"
          End If
          Err.Clear
          End Sub
          Private Sub Command10_Click()
          On Error GoTo errline:
          MSComm1.Output = "5"
          MSComm1.Output = "6"
          MSComm1.Output = "7"
          MSComm1.Output = "8"

          Shape1.FillColor = vbRed
          Shape2.FillColor = vbRed
          Shape3.FillColor = vbRed
          Shape4.FillColor = vbRed
          MSComm1.PortOpen = False
          Timer2.Enabled = False
          Timer3.Enabled = False

          上一頁(yè) 1 2 下一頁(yè)

          關(guān)鍵詞: 51VB數(shù)字

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();