{"id":6519,"date":"2022-01-13T06:34:13","date_gmt":"2022-01-13T06:34:13","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=6519"},"modified":"2023-08-30T10:34:57","modified_gmt":"2023-08-30T05:04:57","slug":"exercise-001-led-control-mealy-machine-implementation-part-1","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/","title":{"rendered":"FSM Lecture 5: Exercise-001 LED control Mealy machine implementation part 1"},"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\" style=\"text-align: left;\">\n<h1 class=\"\" style=\"text-align: center; font-size: 30px; border-width: 0px; line-height: 45px;\"><span style=\"color: #000080;\"><b>Exercise-001 LED control Mealy machine implementation part 1<\/b><\/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=\"color: #000000;\">In this article, let&#8217;s understand LED control mealy machine implementation. <\/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;\">In our application, we also have a couple of states. We have got four states and a couple of events &#8216;ON&#8217; and &#8216;OFF.&#8217; Now all the information let&#8217;s define in the application.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #33cccc;\">enum<\/span> event{\r\n&nbsp; &nbsp;ON,\r\n&nbsp; &nbsp;OFF\r\n};<\/pre>\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 use C\u2019s enumeration data type to define the details. We use the \u2018enum event,\u2019 and define the ON and OFF.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 28px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 36px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000000;\"><span style=\"font-weight: 400;\">Enumeration(enum) in C<\/span><\/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;\">enum or enumeration in C\/C++ is a user-defined data type<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">By using enum, you can define your own data type.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Provides some clarity to your program&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">To use enum, enumerator-list must be known in advance (a finite list set of named integer constant values a data type can take&nbsp; on )<\/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: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #800000;\"><span style=\"font-weight: 400;\">Example 1<\/span><\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; 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;\">I want to create a data type to represent the day of a week.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"padding-left: 90px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 12px; line-height: 30px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"font-weight: 400; color: #000000;\"><span style=\"color: #33cccc;\">enum<\/span> <span style=\"color: #ffffff;\">Day_of_week<\/span><\/span>\r\n<span style=\"color: #ffffff;\"><span style=\"font-weight: 400;\">{\r\n<\/span><span style=\"font-weight: 400;\">   SUNDAY,<\/span><\/span>\r\n<span style=\"color: #ffffff;\"><span style=\"font-weight: 400;\">   MONDAY,\r\n<\/span><span style=\"font-weight: 400;\">   TUESDAY\r\n<\/span><\/span><span style=\"font-weight: 400; color: #000000;\"><span style=\"color: #ffffff;\">};<\/span>\r\n<\/span><span style=\"font-weight: 400; color: #000000;\"><span style=\"color: #33cccc;\">enum<\/span> <span style=\"color: #ffffff;\">Day_of_week whatIsToday;<\/span><\/span>\r\n<span style=\"font-weight: 400; color: #ffffff;\">whatIsToday = MONDAY;<\/span><\/pre>\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 this example, Sunday, Monday, Tuesday are labels. When you use such labels, it adds some clarity to your program. Instead of calling 0, 1, 2, 3, you call it Sunday, Monday, Tuesday, so it adds some clarity to your program. But these are not just labels; these are named integer constants. That&#8217;s why enum binds those named integer constants or labeled integer constants.<\/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;\">In the above example, you see a couple of labels for days of a week, like Sunday, Monday, Tuesday, and other days you can add, separated by a comma. That is called an &#8216;Enumerator-list,&#8217; defined inside an enum tag.&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;\">\u2018enum\u2019 is an enum keyword, and \u2018Day_of_week\u2019 is an enum tag, or that is also called an identifier. The enumerator-list you have to place inside braces; That whole thing is called \u2018enum declaration.\u2019<\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; 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;\">enum Day_of_week whatIsToday;<\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; 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;\">whatIsToday = MONDAY;<\/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;\">After that, you create an \u2018enum Day_of_week\u2019 enumeration type variable. &#8216;enum Day_of_week&#8217; is a data type, &#8216;whatIsToday&#8217; is a variable. And with that variable, you use any of the values in the enumerator-list like SUNDAY, MONDAY, TUESDAY.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"padding-left: 60px; 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;\">enum Day_of_week {<\/span><br \/>\n<span style=\"color: #000000;\">SUNDAY,<\/span><br \/>\n<span style=\"color: #000000;\">MONDAY,<\/span><br \/>\n<span style=\"color: #000000;\">TUESDAY,<\/span><br \/>\n<span style=\"color: #000000;\">};<\/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;\">This is a valid enum declaration. The last member can terminate with a comma, or usually, we don\u2019t give a comma.<\/span><\/p>\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=\"color: #000000;\" data-preserver-spaces=\"true\">And after that, you can create a variable for enum Day_of_week.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; 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;\"><strong>enum Day_of_week today = MONDAY.&nbsp;<\/strong><\/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;\" data-preserver-spaces=\"true\">This is a valid variable creation and initialization.<\/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;\" data-preserver-spaces=\"true\">In C programming, you must mention the \u2018enum\u2019 keyword, the tag or identifier, and then create a variable. But in C++, the \u2018enum\u2019 keyword is not required.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #800000;\"><span style=\"font-weight: 400;\">Example 2:<\/span><\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"padding-left: 60px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 12px; line-height: 30px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"font-weight: 400; color: #ffffff;\"><span style=\"color: #33cccc;\">enum<\/span> {<\/span>\r\n<span style=\"font-weight: 400; color: #ffffff;\">   RAINING,<\/span>\r\n<span style=\"font-weight: 400; color: #ffffff;\">   CLOUDY, <\/span>\r\n<span style=\"font-weight: 400; color: #ffffff;\">   SUNNY<\/span>\r\n<span style=\"font-weight: 400; color: #ffffff;\">};<\/span><\/pre>\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 is also another enum declaration. It doesn\u2019t have any tag\u2014a tagless declaration. You can even use such enums.<\/span><\/p>\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 c99 specification says,&nbsp; an enumerator with = defines its enumeration constant as the value of the constant expression.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"padding-left: 60px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 12px; line-height: 30px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"font-weight: 400; color: #ffffff;\"><span style=\"color: #33cccc;\">enum<\/span> {<\/span>\r\n<span style=\"color: #ffffff;\"><span style=\"font-weight: 400;\">RAINING = 30,\r\n<\/span><span style=\"font-weight: 400;\">CLOUDY, <\/span><\/span>\r\n<span style=\"font-weight: 400; color: #ffffff;\">SUNNY<\/span>\r\n<span style=\"font-weight: 400; color: #ffffff;\">};<\/span><\/pre>\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;\">You can use the assignment operator here to mention the initial constant value. Like 30.<\/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;\">Each subsequent enumerator with no = defines its enumeration constant as the value of the constant expression obtained by adding 1 to the value of the previous enumeration constant. CLOUDY value becomes 31 implicitly, the SUNNY value becomes 32, like that. You can print them, and you would see automatically these labels get a value 1 added to the previous one.<\/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;\">If the first enumerator has no =, the value of its enumeration constant is 0. In example 1, the SUNDAY label has the integer constant 0. 0,1, 2, like that.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000000;\"><span style=\"font-weight: 400;\">Example 3:<\/span><\/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;\">In this example(figure 2), you add the keyword typedef. It doesn\u2019t have a tag. And after that, mention the typedef alias name activity_t and terminate the declaration with a semicolon. That is a typedef alias name.<\/span><\/p>\n<figure id=\"attachment_6531\" aria-describedby=\"caption-attachment-6531\" style=\"width: 688px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-6531 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/figure-2.png\" alt=\"Figure 2. Typedef enum (enumeration)\" width=\"688\" height=\"426\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2.png 688w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2-300x186.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2-600x372.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2-120x74.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2-500x310.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2-200x124.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2-400x248.png 400w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><figcaption id=\"caption-attachment-6531\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Typedef enum<\/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=\"font-weight: 400; color: #000000;\">That\u2019s about the enum declarations.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 28px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 40px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><strong><span style=\"text-decoration: underline;\">Implementation of state machine<\/span><\/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><span style=\"font-weight: 400; color: #000000;\">Nested switch approach<\/span><\/li>\n<li><span style=\"font-weight: 400; color: #000000;\">State table approach<\/span><\/li>\n<li><span style=\"font-weight: 400; color: #000000;\">State handler approach<\/span><\/li>\n<\/ul>\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;\">There are many ways to implement the state machine or state machine handler. You can use &#8216;nested switch&#8217; or &#8216;nested if-else&#8217; or &#8216;if-else-if ladder,&#8217; so there is something called &#8216;state table approach&#8217; and &#8216;state handler approach.&#8217; <\/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;\">Out of these three states, the state handler approach is more efficient, and it helps you implement less redundant code.<\/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;\">But, as a starting point, let&#8217;s use a nested switch or nested if-else-if ladder. Below code snippet<\/span><span style=\"color: #000000;\">&nbsp;shows the switch case statement.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"box-shadow: #cecece 0px 0px 0px 0px inset; font-size: 12px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">void<\/span> light_state_machine(<span style=\"color: #008000;\">uint8_t<\/span> event)\r\n{\r\n<span style=\"color: #33cccc;\">  switch<\/span>(curr_state)\r\n  {\r\n<span style=\"color: #33cccc;\">     case<\/span> LIGHT_OFF:{\r\n<span style=\"color: #33cccc;\">      switch<\/span>(event){\r\n<span style=\"color: #33cccc;\">       case<\/span> ON:{\r\n         light_change_intensity(PIN_LED,LIGHT_BRIGHT_DIM);\r\n\r\n<span style=\"color: #33cccc;\">       break<\/span>;\r\n     }\r\n    }\r\n<span style=\"color: #33cccc;\">   break<\/span>;\r\n }<\/pre>\n<p class=\"\" style=\"text-align: center;\"><span style=\"color: #000000;\">Switch case Example<\/span><\/p>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 26px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 40px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000000;\">Serial:<\/span><\/p>\n<figure id=\"attachment_6535\" aria-describedby=\"caption-attachment-6535\" style=\"width: 662px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-6535 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/serial.png\" alt=\"LED control Mealy machine implementation \" width=\"662\" height=\"315\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial.png 1889w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-300x143.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-768x366.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-1024x487.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-600x286.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-120x57.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-500x238.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-200x95.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-400x190.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-800x381.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-1200x571.png 1200w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><figcaption id=\"caption-attachment-6535\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Arduino serial object<\/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;\">How to receive the 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=\"color: #000000;\">We will receive the events from the host over the serial communication. For that, we have to refer to the Arduino serial object. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">For that, go to documentation, reference, and the serial object you can access Serial. <\/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;\">You understand the serial object and its related APIs or functions in this serial. You have to configure the baudrate, number of bits you want to send as a payload,&nbsp;<span style=\"font-weight: 400;\">number of stop bits, etc. So, all those things can be done in one go by using a function called begin().<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 25px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 42px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000000;\">Serial.begin()<\/span><\/p>\n<figure id=\"attachment_6536\" aria-describedby=\"caption-attachment-6536\" style=\"width: 661px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-6536\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/serial-begin.png\" alt=\"LED control Mealy machine, enumeration\" width=\"661\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin.png 1465w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-300x180.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-768x461.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-1024x614.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-600x360.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-120x72.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-500x300.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-200x120.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-400x240.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-800x480.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-1200x720.png 1200w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><figcaption id=\"caption-attachment-6536\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Serial.begin()<\/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 serial.begin has two flavors here. You have to mention the serial object and its associated method, like that you have to use because it\u2019s a C++ framework.&nbsp;<\/span><\/p>\n<figure id=\"attachment_6537\" aria-describedby=\"caption-attachment-6537\" style=\"width: 660px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6537\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/01\/serial-begin-code.png\" alt=\"enumeration\" width=\"660\" height=\"290\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code.png 1513w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-300x132.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-768x338.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-1024x450.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-600x264.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-120x53.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-500x220.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-200x88.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-400x176.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-800x352.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/serial-begin-code-1200x527.png 1200w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><figcaption id=\"caption-attachment-6537\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Serial.begin()<\/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;\">All setup related activities you have to do in a setup function. Because the setup function executes only one time. <\/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;\">When you give power to the Arduino board, the microcontroller first jumps to the setup function, and it executes the setup related activities, then it goes and hangs in a loop function. The loop function is executed repeatedly. <\/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;\">Let\u2019s use one baudrate 115200 or any values like 9600, 4800, or 1mbps, upto 2mbps you can use for Arduino Uno.<\/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=\"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;\">C<span style=\"font-weight: 400;\">lick here:&nbsp;<\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Exercise-001 LED control Mealy machine implementation part 1 &nbsp; &nbsp; In this article, let&#8217;s understand LED control mealy machine implementation. In our application, we also have a couple of states. We have got four states and a couple of events &#8216;ON&#8217; and &#8216;OFF.&#8217; Now all the information let&#8217;s define in the application. enum event{ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6531,"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-6519","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>LED Control Mealy Machine Implementation Part 1: Enumerations and State Transitions<\/title>\n<meta name=\"description\" content=\"Dive into the world of LED control using Mealy machine implementation. Learn about enums in C programming, their significance, and how to\" \/>\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\/exercise-001-led-control-mealy-machine-implementation-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LED Control Mealy Machine Implementation Part 1: Enumerations and State Transitions\" \/>\n<meta property=\"og:description\" content=\"Dive into the world of LED control using Mealy machine implementation. Learn about enums in C programming, their significance, and how to\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/\" \/>\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-13T06:34:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-30T05:04:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"688\" \/>\n\t<meta property=\"og:image:height\" content=\"426\" \/>\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\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"FSM Lecture 5: Exercise-001 LED control Mealy machine implementation part 1\",\"datePublished\":\"2022-01-13T06:34:13+00:00\",\"dateModified\":\"2023-08-30T05:04:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/\"},\"wordCount\":978,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/figure-2.png\",\"keywords\":[\"Finite state Machine(FSM)\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/\",\"name\":\"LED Control Mealy Machine Implementation Part 1: Enumerations and State Transitions\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/figure-2.png\",\"datePublished\":\"2022-01-13T06:34:13+00:00\",\"dateModified\":\"2023-08-30T05:04:57+00:00\",\"description\":\"Dive into the world of LED control using Mealy machine implementation. Learn about enums in C programming, their significance, and how to\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/figure-2.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/figure-2.png\",\"width\":688,\"height\":426,\"caption\":\"Figure 2. Typedef enum\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-001-led-control-mealy-machine-implementation-part-1\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FSM Lecture 5: Exercise-001 LED control Mealy machine implementation part 1\"}]},{\"@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":"LED Control Mealy Machine Implementation Part 1: Enumerations and State Transitions","description":"Dive into the world of LED control using Mealy machine implementation. Learn about enums in C programming, their significance, and how to","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\/exercise-001-led-control-mealy-machine-implementation-part-1\/","og_locale":"en_US","og_type":"article","og_title":"LED Control Mealy Machine Implementation Part 1: Enumerations and State Transitions","og_description":"Dive into the world of LED control using Mealy machine implementation. Learn about enums in C programming, their significance, and how to","og_url":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-01-13T06:34:13+00:00","article_modified_time":"2023-08-30T05:04:57+00:00","og_image":[{"width":688,"height":426,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2.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\/exercise-001-led-control-mealy-machine-implementation-part-1\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"FSM Lecture 5: Exercise-001 LED control Mealy machine implementation part 1","datePublished":"2022-01-13T06:34:13+00:00","dateModified":"2023-08-30T05:04:57+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/"},"wordCount":978,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2.png","keywords":["Finite state Machine(FSM)"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/","url":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/","name":"LED Control Mealy Machine Implementation Part 1: Enumerations and State Transitions","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2.png","datePublished":"2022-01-13T06:34:13+00:00","dateModified":"2023-08-30T05:04:57+00:00","description":"Dive into the world of LED control using Mealy machine implementation. Learn about enums in C programming, their significance, and how to","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/01\/figure-2.png","width":688,"height":426,"caption":"Figure 2. Typedef enum"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/exercise-001-led-control-mealy-machine-implementation-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FSM Lecture 5: Exercise-001 LED control Mealy machine implementation part 1"}]},{"@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\/6519","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=6519"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/6519\/revisions"}],"predecessor-version":[{"id":15670,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/6519\/revisions\/15670"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/6531"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=6519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=6519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=6519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}