Real-time control software The second week of work

Source: Internet
Author: User

First make each variable name

Entry gate sensor: sensor_in;

Gate sensor: sensor_out;

Ascent of landing Rod: gan.raise ();

Landing lever descent: Gan.down ();

Light signal: Light (1 for green, 0 for red);

Pass state: A0 is forbidden to pass, A1 is allowed to pass;

Write (Judge event in state) C code snippet

Cur_state =nxt_state; Switch(cur_state)//Judging events in the current state{                 CaseA0://in the A0 state        if(sensor_in==1)//if the input gate sensor detects a signal{gan.raise ();//the pole goes up and the light turns greenlight==1; Nxt_state= A1;//State Change A1        }                Else        {             Break; }        CaseA1://in the A1 state        if(sensor_out==1)//signal detected by the gate sensor{gan.down ();//The pole drops, the lamp turns redlight==0; Nxt_state= A0;//State Change A0        }                   Else{ Break; }}

Real-time control software The second week of work

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.