{"id":7026,"date":"2022-01-31T09:02:28","date_gmt":"2022-01-31T09:02:28","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=7026"},"modified":"2023-02-03T15:55:33","modified_gmt":"2023-02-03T10:25:33","slug":"fsm-lecture-21-exercise-003-data-structure-explanation","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/","title":{"rendered":"FSM Lecture 21: Exercise-003 Data structure explanation"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 50px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><strong>Exercise-003 Data structure explanation<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the <span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"http:\/\/fastbitlab.com\/fsm-lecture-20-create-new-project-visual-studio-code\/\" target=\"_blank\" rel=\"noopener\">previous article<\/a><\/span>, we set up the IDE, and in this article, let\u2019s start implementing.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">The first step is to create a few more header files and source files for our project. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">We have got main.cpp. The extension is &#8216;CPP&#8217; here, the C++ file, because the Arduino framework uses the C++ programming language. But we will code using the C programming language syntaxes. <\/span><\/p>\n<figure id=\"attachment_7029\" aria-describedby=\"caption-attachment-7029\" style=\"width: 704px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\" wp-image-7029\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/Headerfile-creation.png\" alt=\"Figure 1. Header file creation\" width=\"704\" height=\"419\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation.png 1715w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-300x179.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-768x457.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-1024x610.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-600x357.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-120x71.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-500x298.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-200x119.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-400x238.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-800x476.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Headerfile-creation-1200x714.png 1200w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><figcaption id=\"caption-attachment-7029\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Header file creation<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\" data-preserver-spaces=\"true\">Let&#8217;s create a header file, as shown in Figure 1.&nbsp;<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li><span style=\"color: #000000;\" data-preserver-spaces=\"true\">Just select src, right-click, new file, and let me call it &#8216;main.h&#8217;, a header file.&nbsp;<\/span><\/li>\n<li><span style=\"color: #000000;\" data-preserver-spaces=\"true\">And also, we are using LCD in this project; create &#8216;lcd.cpp&#8217;, a source file to keep LCD-related code.<\/span><\/li>\n<li><span style=\"color: #000000;\" data-preserver-spaces=\"true\">And also one more file &#8216;lcd.h&#8217;.&nbsp;<\/span><\/li>\n<li><span style=\"color: #000000;\" data-preserver-spaces=\"true\">And also, let&#8217;s segregate the state machine implementation into a separate file. I will call it protimer_state_machine. This file is a .cpp file, where we will keep all state machine implementation. That is the state machine diagram implementation. Instead of putting all the code into main.cpp, I&#8217;m just segregating this.&nbsp; &nbsp;<\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the main.cpp, #include \u201cmain.h\u201d as shown in Figure 2.<\/span><\/p>\n<figure id=\"attachment_7030\" aria-describedby=\"caption-attachment-7030\" style=\"width: 694px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\" wp-image-7030\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/main.png\" alt=\"Figure 2. main.h \" width=\"694\" height=\"372\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main.png 1911w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-768x412.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-1024x549.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-600x322.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-400x215.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-800x429.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/main-1200x644.png 1200w\" sizes=\"(max-width: 694px) 100vw, 694px\" \/><figcaption id=\"caption-attachment-7030\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. main.h<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The <strong>Arduino.h<\/strong>, you just keep in the main.h file, which is required if you are using the PlatformIO Extension (Figure 3).<\/span><\/p>\n<figure id=\"attachment_7031\" aria-describedby=\"caption-attachment-7031\" style=\"width: 733px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\" wp-image-7031\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/arduino.png\" alt=\"Figure 3.Arduino.h \" width=\"733\" height=\"393\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-768x411.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-1024x549.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-800x429.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/arduino-1200x643.png 1200w\" sizes=\"(max-width: 733px) 100vw, 733px\" \/><figcaption id=\"caption-attachment-7031\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Arduino.h<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_7032\" aria-describedby=\"caption-attachment-7032\" style=\"width: 737px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-7032\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/include-guards.png\" alt=\"Figure 4.Include guards in main.h file\" width=\"737\" height=\"394\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards.png 1911w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-768x411.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-1024x548.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-800x428.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/include-guards-1200x642.png 1200w\" sizes=\"(max-width: 737px) 100vw, 737px\" \/><figcaption id=\"caption-attachment-7032\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Include guards in main.h file<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">In the main.h, let&#8217;s give include guards. The red line shows the include guards in Figure 4 and ends that if statement using &#8216;endif.&#8217; <\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><span style=\"font-weight: 400;\">And in the lcd.h file, we also use include guards.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #993300;\"><strong>Data structures<\/strong><\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Define various signals of the application using enum<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Define various states of the application using enum<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Define the main application structure<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Define structures to represent events&nbsp;<\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">First, Signals and States. You just add all the definitions(Figure 5) to \u201cmain.h\u201d. I have just used an \u2018enum\u2019 to represent various application signals. Also, I have included ENTRY and EXIT enumerators. They are 2 represent the internal activity signals.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And after that, create one enum definition for various states of the application, as shown in figure 5.<\/span><\/p>\n<figure id=\"attachment_7033\" aria-describedby=\"caption-attachment-7033\" style=\"width: 586px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7033 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/signals-and-state.png\" alt=\"Data structure\" width=\"586\" height=\"238\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state.png 1203w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-300x122.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-768x312.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-1024x416.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-600x244.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-120x49.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-500x203.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-669x272.png 669w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-200x81.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-400x163.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-800x325.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state-1200x488.png 1200w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><figcaption id=\"caption-attachment-7033\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Signals and states<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, the main application structure. You should also keep it in main.h, as shown in Figure 6. It shows the variables; you can also call them extended state variables.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Current time, elapsed time, and productive time are unsigned values. And also, there is one state variable, active_state, that holds the current active state of this main application object.<\/span><\/p>\n<figure id=\"attachment_7034\" aria-describedby=\"caption-attachment-7034\" style=\"width: 576px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7034 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/Main-application-structure.png\" alt=\"Data structure\" width=\"576\" height=\"273\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure.png 860w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-300x142.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-768x364.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-600x285.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-120x57.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-500x237.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-200x95.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-400x190.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Main-application-structure-800x380.png 800w\" sizes=\"(max-width: 576px) 100vw, 576px\" \/><figcaption id=\"caption-attachment-7034\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Main application structure<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_7035\" aria-describedby=\"caption-attachment-7035\" style=\"width: 666px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7035 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/Events-2.png\" alt=\"Data structure\" width=\"666\" height=\"297\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2.png 1191w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-300x134.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-768x342.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-1024x457.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-600x268.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-120x54.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-500x223.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-200x89.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-400x178.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-2-800x357.png 800w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><figcaption id=\"caption-attachment-7035\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Events<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And after that, the Events, we have got two types of events in this application. User generated and system generated events.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The user-generated event has only the signal component and doesn\u2019t have any associated parameters. Create one structure protimer_user_event_t, and just use one variable \u2018signal\u2019 as the member element to represent the signal. (Figure 7)&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And after that, for tick events, this is system generated, or it\u2019s a synchronous event. And it has two components, \u2018Signal\u2019 and the associated parameter \u2018Sub-second.\u2019<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Instead of doing this, there is one disadvantage with this approach.&nbsp;<\/span><\/p>\n<figure id=\"attachment_7036\" aria-describedby=\"caption-attachment-7036\" style=\"width: 596px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7036 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/state-machine-implementation.png\" alt=\"Data structure\" width=\"596\" height=\"308\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation.png 1731w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-300x155.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-768x396.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-1024x528.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-600x310.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-120x62.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-500x258.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-200x103.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-400x206.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-800x413.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/state-machine-implementation-1200x619.png 1200w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><figcaption id=\"caption-attachment-7036\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. State machine Implementation<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let\u2019s say you have a state machine function or state machine implementation. And for the state machine implementation, you have to pass the event. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Events are represented as structures. Sometimes you have to pass user-generated events, and sometimes you have to pass system generated events(shown in Figure 8). That means now there should be two receiving parameters. That doesn\u2019t look good.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_7037\" aria-describedby=\"caption-attachment-7037\" style=\"width: 611px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7037 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/Events-1-1.png\" alt=\"Data structure\" width=\"611\" height=\"383\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1.png 1011w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-300x188.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-768x482.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-600x376.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-320x202.png 320w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-120x75.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-500x314.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-200x125.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-400x251.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/Events-1-1-800x502.png 800w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><figcaption id=\"caption-attachment-7037\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Events<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">What you do is you create one super event structure or generic event structure, called event_t, and you include the signal value there(shown in Figure 9).<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This method&#8217;s advantage is that you can just send a pointer to this member element. And then downcast to get the parent structure address.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 25px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px;\"><span style=\"color: #000000;\">click here:<\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\">https:\/\/fastbitlab.com\/course1<\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Exercise-003 Data structure explanation &nbsp; &nbsp; In the previous article, we set up the IDE, and in this article, let\u2019s start implementing. The first step is to create a few more header files and source files for our project. We have got main.cpp. The extension is &#8216;CPP&#8217; here, the C++ file, because the Arduino [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7033,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[17],"class_list":["post-7026","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-finite-state-machine","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Data structure explanation - Finite State Machine(FSM)<\/title>\n<meta name=\"description\" content=\"Data structure explanation - Finite State Machine(FSM). The first step is to create a few more header files and source files for our project.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data structure explanation - Finite State Machine(FSM)\" \/>\n<meta property=\"og:description\" content=\"Data structure explanation - Finite State Machine(FSM). The first step is to create a few more header files and source files for our project.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-31T09:02:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-03T10:25:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1203\" \/>\n\t<meta property=\"og:image:height\" content=\"489\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"FSM Lecture 21: Exercise-003 Data structure explanation\",\"datePublished\":\"2022-01-31T09:02:28+00:00\",\"dateModified\":\"2023-02-03T10:25:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/\"},\"wordCount\":744,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/signals-and-state.png\",\"keywords\":[\"Finite state Machine(FSM)\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/\",\"name\":\"Data structure explanation - Finite State Machine(FSM)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/signals-and-state.png\",\"datePublished\":\"2022-01-31T09:02:28+00:00\",\"dateModified\":\"2023-02-03T10:25:33+00:00\",\"description\":\"Data structure explanation - Finite State Machine(FSM). The first step is to create a few more header files and source files for our project.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/signals-and-state.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/signals-and-state.png\",\"width\":1203,\"height\":489,\"caption\":\"Figure 5. Signals and states\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-21-exercise-003-data-structure-explanation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FSM Lecture 21: Exercise-003 Data structure explanation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Data structure explanation - Finite State Machine(FSM)","description":"Data structure explanation - Finite State Machine(FSM). The first step is to create a few more header files and source files for our project.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/","og_locale":"en_US","og_type":"article","og_title":"Data structure explanation - Finite State Machine(FSM)","og_description":"Data structure explanation - Finite State Machine(FSM). The first step is to create a few more header files and source files for our project.","og_url":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-01-31T09:02:28+00:00","article_modified_time":"2023-02-03T10:25:33+00:00","og_image":[{"width":1203,"height":489,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"FSM Lecture 21: Exercise-003 Data structure explanation","datePublished":"2022-01-31T09:02:28+00:00","dateModified":"2023-02-03T10:25:33+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/"},"wordCount":744,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state.png","keywords":["Finite state Machine(FSM)"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/","url":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/","name":"Data structure explanation - Finite State Machine(FSM)","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state.png","datePublished":"2022-01-31T09:02:28+00:00","dateModified":"2023-02-03T10:25:33+00:00","description":"Data structure explanation - Finite State Machine(FSM). The first step is to create a few more header files and source files for our project.","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/signals-and-state.png","width":1203,"height":489,"caption":"Figure 5. Signals and states"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-21-exercise-003-data-structure-explanation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FSM Lecture 21: Exercise-003 Data structure explanation"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=7026"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7026\/revisions"}],"predecessor-version":[{"id":13861,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7026\/revisions\/13861"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/7033"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=7026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=7026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=7026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}