Challenge

Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear

AIM OF THE PROJECT :

To write a program for controlling the retraction and extension of the airplane landing gear using finite state machine.

OBJECTIVE :

Using finite state machine the airplane landing gear is controlled. Finite state machine is a concept in c which has number of states and which transfers from one state to another based on the input provided by the user. The FSM are used because they are easily readable and expanded for further requirement.

In this program there are six states and seven functions are used and the enum is used to represent the state types and limit switch input and which makes the code easy to read and rewritable. In program first seven functions are declared with return type void which means there will be no return type and a keyword typedef which we can give a new name for a existing data type. typedef are used along with enum which are integer constants which a user defined data type.

A State table is written for totally six states for each row in a state table represents the output to be displayed to each separate state and finite state machine is initialized with the first state and based on the input it moves to next state or the the loop remains in that state. If the condition satisfy in the first state then current state moves to next state by this way we have represented the working of a landing gear in a airplane using the Finite State Machine. In the main function given that while (1) which means loop runs continuously. so to stop the loop a global character is declared as exit_flag and in the last state the it asks the user to continue for further it user gives the input as 'y' then the while loop continues or if the user gives as 'n' then the loop ends.

The program is written in STM Cube IDE is taken screenshots and pasted below and the code is also pasted with result after execution of program.

SCREENSHOTS OF CODE :

RESULT :

After executing the program by giving the inputs the output is displayed in the console and when the given input equals the condition given in the current state then it moves to next state and by meeting the requirements of that state then it moves to next state like this the loop continues. when the input given doesn't move to next state, the loop will rotate in that state till getting the correct input and after reaching the last state it asks whether the loop to continue where exit flag is used to exit the loop if user wants to rotate the loop then the loop or else it ends.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.