Challenge

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

Overview of the Project: (5 to 6 lines)

In this project, controlling the retraction and extension of Airplane’s landing gear can be implemented using Finite State Machine (FSM). FSM is the most efficient algorithm which is mathematical model of computation.

Goals ( 2 to 3 points)

  • Controlling the direction of Valve.
  • Controlling the retraction and extension of Airplane’s landing gear.

Key Highlights of the Project: (4 to 5 points)

A direction valve is controlled by the software to allow the hydraulic pressure to either raise or lower the landing gear.

Deliverables of this project: (4 to 5 points)

Implementing the control for the retraction and extension of Airplane’s landing gear using the Finite state machine with the knowledge of various states of switch and gear.

Expected Outcomes: (4 to 5 points)

The student will be getting the Knowledge of Finite State Machine algorithm which is used to achieve the control over the retraction and extension of Airplane’s landing gear using the switch and gear states of Airplane.

solution:

/*
* Landing_Gear.c
*
* Created on: June 27, 2023
* Author: vinoth kumar
*/
#include <stdio.h>

// Define the states
typedef enum
{
GEAR_UP,
GEAR_DOWN,
GEAR_TRANSITION
} GearState;

// Define the events
typedef enum
{
SWITCH_UP,
SWITCH_DOWN
} Event;

// Function to handle state transitions
void transition(GearState* currentState, Event event)
{
switch (*currentState)
{
case GEAR_UP:
if (event == SWITCH_DOWN)
{
*currentState = GEAR_TRANSITION;
printf("Landing gear is transitioning to the extended state.\n");
printf("Light indication is red.\n");
}
break;
case GEAR_DOWN:
if (event == SWITCH_UP)
{
*currentState = GEAR_TRANSITION;
printf("Landing gear is transitioning to the retracted state.\n");
printf("Light indication is red.\n");
}
break;
case GEAR_TRANSITION:
if (event == SWITCH_UP)
{
*currentState = GEAR_UP;
printf("Landing gear is now in the extended state.\n");
printf("Light indication is off.\n");
}
else if (event == SWITCH_DOWN)
{
*currentState = GEAR_DOWN;
printf("Landing gear is now in the retracted state.\n");
printf("Light indication is green.\n");
}
break;
}
}

int main()
{
GearState currentState = GEAR_UP;

// Simulate events
transition(&currentState, SWITCH_DOWN);
transition(&currentState, SWITCH_UP);
transition(&currentState, GEAR_TRANSITION);

return 0;
}

output:

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.