Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
| current state | valve | output | next state |
| state A | pressure =0 | extension | state B |
| state B | prtessure= 1 | retraction | state A |
#include<stdio.h>
static volatile int pressure;
static volatile int output;
void Init_Landing _gear()
{
pressure = 0;
output = 0;
printf("Landing_gear is initialized and program is in state_A & value of output is %d\n", ouput);
}
void state_B()
{
output = 1;
printf("program is in state _B and value of output is %d\n", output);
}
void state_A(){
output = 0;
printf("program is in state_A and value of output is %d\n", output);
}
int main()
{
Init_Landing_gear();
while(1){
switch(valv){
case 1: state_B();
break;
case 2: state_A();
break;
default : break;
}
clock++;
printf("pressure value is : %d\n", pressure);
}
}