{"id":8349,"date":"2022-03-12T04:09:26","date_gmt":"2022-03-12T04:09:26","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=8349"},"modified":"2023-08-24T10:22:10","modified_gmt":"2023-08-24T04:52:10","slug":"coding-for-the-ticking-state","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/","title":{"rendered":"FSM Lecture 67: Exercise-007 Coding for the TICKING state"},"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; line-height: 50px;\"><strong><span style=\"color: #000080;\">Exercise-007 Coding for the TICKING state<\/span><\/strong><\/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<h3 class=\"\" style=\"border-width: 0px; font-size: 22px; 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: #000080;\">Coding for the TICKING state<\/span><\/h3>\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=\"font-weight: 400; color: #000000;\">In the previous article, we added the Initial Transition Action. And now, in this article, let&#8217;s code for &#8216;Ticking&#8217;&nbsp; state. The purpose of the Ticking state is to show the current time or display the current time.<\/span><\/p>\n<figure id=\"attachment_8352\" aria-describedby=\"caption-attachment-8352\" style=\"width: 1280px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-8352\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-1-24.png\" alt=\"Figure 1. Ticking state\" width=\"1280\" height=\"578\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24.png 1280w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-300x135.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-768x347.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-1024x462.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-600x271.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-120x54.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-500x226.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-200x90.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-400x181.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-800x361.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24-1200x542.png 1200w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><figcaption id=\"caption-attachment-8352\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Ticking state<\/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;\">Whenever the control reaches Ticking state, we have to show the time to the user on the LCD display. That&#8217;s why let&#8217;s define some Entry actions for this state.&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;\">You see \u2018entry\u2019 and \u2018exit\u2019 sections on the right-hand side when you click over that state. And here, you can add the actual code, and you can also add pseudo code here(Figure 1). This is a space for pseudocode space, like that.&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;\">When you define both entry and exit actions, the letter &#8216;e&#8217; and &#8216;x&#8217; appears here with a &#8216;\/&#8217; character, which signifies that the entry or exit action has been defined.&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;\">First of all, the entry action of the Ticking state will display_the_curr_time.&nbsp; And let&#8217;s use some functions for that.<\/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 file contains various functions, helper functions, and other housekeeping functions to display various information on the LCD. And you can refer to that code. So, you can study that code, and you can copy that code to your project.<\/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;\">First of all, let&#8217;s look at a function called display_curr_time, which is very simple. This function actually converts the current time into a string, and it uses the function display_write to display it on the LCD. <\/span><\/p>\n<figure id=\"attachment_8353\" aria-describedby=\"caption-attachment-8353\" style=\"width: 1537px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-8353\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-2-20.png\" alt=\"Figure 2. Display_curr_time function\" width=\"1537\" height=\"809\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20.png 1537w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-300x158.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-768x404.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-1024x539.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-600x316.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-500x263.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-200x105.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-400x211.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-800x421.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-2-20-1200x632.png 1200w\" sizes=\"(max-width: 1537px) 100vw, 1537px\" \/><figcaption id=\"caption-attachment-8353\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Display_curr_time function<\/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;\">\u2018time24h\u2019 variable stores the current time, and I&#8217;m getting the current time using the Clock_Alarm_get_curr_time function, which we created earlier. And I divide that by 10 because I want to consider the number of seconds. I&#8217;m not interested in milliseconds. That&#8217;s why I&#8217;m dividing that by 10. Now, the time24h variable contains the copy of the current time.&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;\">Then, if the MODE_24H, I will display that as it is. I&#8217;ll copy this value into a time variable. If the time mode variable is not 24H, we have to present the time in 12H format.&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;\">Please note that the time will always be in 24-hour format, whatever this function returns. That&#8217;s why we have to convert here 24-hour format to a 12-hour format. convert_12hformat_to_24h&nbsp; is a helper function defined in this file.<\/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;\">You can take a look at these functions, convert_12hformat_to_24h format and convert_12format_to_12 hour format. This is just simple logic to convert to study those functions.<\/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;\">Once you have that time information, then integertime_to_string function; this is another helper function. This function converts the integer time to a string value in hh:mm:ss format.&nbsp;<\/span><\/p>\n<figure id=\"attachment_8354\" aria-describedby=\"caption-attachment-8354\" style=\"width: 1312px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-8354\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-3-20.png\" alt=\"Figure 3. integertime_to_string helper function\" width=\"1312\" height=\"477\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20.png 1312w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-300x109.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-768x279.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-1024x372.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-600x218.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-120x44.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-500x182.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-200x73.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-400x145.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-800x291.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-20-1200x436.png 1200w\" sizes=\"(max-width: 1312px) 100vw, 1312px\" \/><figcaption id=\"caption-attachment-8354\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. integertime_to_string helper function<\/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=\"color: #000000;\"><span style=\"font-weight: 400;\">integertime_to_string is another free operation, which takes &#8216;integer&#8217; time and converts into a &#8216;string&#8217; in HH:MM:SS format. For that, it just extracts hour information, minutes information, and the seconds information using these macros GET_HOUR, GET_MIN, GET_SEC. These are simple macros.<\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/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=\"font-weight: 400; color: #000000;\">The macros are defined here, shown in Figure 4.&nbsp;<\/span><\/p>\n<figure id=\"attachment_8355\" aria-describedby=\"caption-attachment-8355\" style=\"width: 1509px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8355\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-4-19.png\" alt=\"Figure 4. GET_HOUR,GET_MIN, GET_SEC macros\" width=\"1509\" height=\"600\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19.png 1509w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-300x119.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-768x305.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-1024x407.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-600x239.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-120x48.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-500x199.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-200x80.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-400x159.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-800x318.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-4-19-1200x477.png 1200w\" sizes=\"(max-width: 1509px) 100vw, 1509px\" \/><figcaption id=\"caption-attachment-8355\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. GET_HOUR, GET_MIN, GET_SEC macros<\/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;\">For example, GET_HOUR. It takes the number of seconds and divides it by 3600. That&#8217;s it. That is the number of hours. And for minutes, it divides by 60 first and takes the mode of 60, like that.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8356\" aria-describedby=\"caption-attachment-8356\" style=\"width: 1413px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8356\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-5-18.png\" alt=\"Figure 5. Dispaly_curr_time function\" width=\"1413\" height=\"621\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18.png 1413w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-300x132.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-768x338.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-1024x450.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-600x264.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-120x53.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-500x220.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-200x88.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-400x176.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-800x352.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-18-1200x527.png 1200w\" sizes=\"(max-width: 1413px) 100vw, 1413px\" \/><figcaption id=\"caption-attachment-8356\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Dispaly_curr_time function<\/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;\">After that, we also have to show the sub-second field. time_as_string.concat(\u2018.\u2019); time_as_string.concat(ss);&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;\">time24h % 10UL shows how the sub-second field is obtained; that is concatenated to the value which is returned by&nbsp; integertime_to_string function. Since I&#8217;m using the string object of the Arduino framework, you can access all these &#8216;concat&#8217; methods. A &#8216;concat&#8217; is a method of the String object.<\/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, if the mode is 12H, we should also print or concatenate the AM or PM information. get_am_or_pm(time24h) is another helper function to extract whether the given 24-hour format is AM or PM. Then, display_write is another helper function.<\/span><\/p>\n<figure id=\"attachment_8357\" aria-describedby=\"caption-attachment-8357\" style=\"width: 1171px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8357\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-6-18.png\" alt=\"Figure 6. display_curr_time\" width=\"1171\" height=\"313\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18.png 1171w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-300x80.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-768x205.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-1024x274.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-600x160.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-120x32.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-500x134.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-200x53.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-400x107.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-18-800x214.png 800w\" sizes=\"(max-width: 1171px) 100vw, 1171px\" \/><figcaption id=\"caption-attachment-8357\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. display_curr_time<\/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;\">The display current time also takes two other parameters, the row and column number of the LCD; you have to mention that in the display_write function.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8358\" aria-describedby=\"caption-attachment-8358\" style=\"width: 1285px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8358 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-7-16.png\" alt=\"Coding for the TICKING state\" width=\"1285\" height=\"333\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16.png 1285w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-300x78.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-768x199.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-1024x265.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-600x155.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-120x31.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-500x130.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-200x52.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-400x104.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-800x207.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-7-16-1200x311.png 1200w\" sizes=\"(max-width: 1285px) 100vw, 1285px\" \/><figcaption id=\"caption-attachment-8358\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. display_write function<\/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 display_write is just another helper function; it calls these two functions of the lcd.cpp. First, it sets the cursor and then prints the string.&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;\">Create display_curr_time function now (Figure 6). This function has access to the &#8216;me&#8217; pointer, so I&#8217;ll create display_curr_time as a class operation, which is non-static because I want access to this &#8216;me&#8217; pointer.&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;\">That&#8217;s why I go to ClockAlarm and Add class operation; I&#8217;ll call this display_curr_time, return type void, the visibility you can keep it as public, which is a non-static.(Figure 8)<\/span><\/p>\n<figure id=\"attachment_8359\" aria-describedby=\"caption-attachment-8359\" style=\"width: 1055px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8359 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-8-14.png\" alt=\"Coding for the TICKING state\" width=\"1055\" height=\"490\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14.png 1055w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-300x139.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-768x357.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-1024x476.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-600x279.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-120x56.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-500x232.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-200x93.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-400x186.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-14-800x372.png 800w\" sizes=\"(max-width: 1055px) 100vw, 1055px\" \/><figcaption id=\"caption-attachment-8359\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Adding display_curr_time class operation<\/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;\">And let&#8217;s add a parameter. The first parameter is row, another one column uint8_t, as shown in Figure 9.<\/span><\/p>\n<figure id=\"attachment_8360\" aria-describedby=\"caption-attachment-8360\" style=\"width: 904px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8360 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-9-13.png\" alt=\"Coding for the TICKING state\" width=\"904\" height=\"518\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13.png 904w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-300x172.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-768x440.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-600x344.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-120x69.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-500x287.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-200x115.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-400x229.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-13-800x458.png 800w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><figcaption id=\"caption-attachment-8360\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Adding parameter<\/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 code for the Ticking state, copy-paste the display_curr_time function codes(Figure 5). Save it, generate the code.<\/span><\/p>\n<figure id=\"attachment_8367\" aria-describedby=\"caption-attachment-8367\" style=\"width: 1280px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8367 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Fig-10.png\" alt=\"Coding for the TICKING state\" width=\"1280\" height=\"607\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10.png 1280w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-300x142.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-768x364.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-1024x486.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-600x285.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-120x57.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-500x237.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-200x95.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-400x190.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-800x379.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-10-1200x569.png 1200w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><figcaption id=\"caption-attachment-8367\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Code<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8362\" aria-describedby=\"caption-attachment-8362\" style=\"width: 1733px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8362 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-11-7.png\" alt=\"Coding for the TICKING state\" width=\"1733\" height=\"705\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7.png 1733w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-300x122.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-768x312.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-1024x417.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-600x244.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-120x49.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-500x203.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-669x272.png 669w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-200x81.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-400x163.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-800x325.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-7-1200x488.png 1200w\" sizes=\"(max-width: 1733px) 100vw, 1733px\" \/><figcaption id=\"caption-attachment-8362\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. Clock_Alarm_display_curr_time<\/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;\">Here it is Clock_Alarm_display_curr_time, and this function I&#8217;m going to call from Ticking state as Entry action. Provide the &#8216;me&#8217; pointer, row, and column number.<\/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;\"><b>Clock_Alarm_display_curr_time(me, TICKING_CURR_TIME_ROW,TICKING_CURR_TIME_COL);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8369\" aria-describedby=\"caption-attachment-8369\" style=\"width: 1280px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8369 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Fig-12.png\" alt=\"Coding for the TICKING state\" width=\"1280\" height=\"489\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12.png 1280w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-300x115.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-768x293.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-1024x391.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-600x229.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-120x46.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-500x191.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-200x76.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-400x153.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-800x306.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Fig-12-1200x458.png 1200w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><figcaption id=\"caption-attachment-8369\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 12. ClockAlarm_SM.h file<\/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-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=\"font-weight: 400; color: #000000;\">Let&#8217;s go to the SM.h, let&#8217;s define some macros.&nbsp;<\/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=\"font-weight: 400; color: #000000;\">#define TICKING_CURR_TIME_ROW, the row is 0;&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;\"># define TICKING_CURR_TIME_COL, and for the column position, I will select 3.&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;\">So, we will mention that in Ticking state as Entry action. First, you mention the row and then the column. Generate the code.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; line-height: 26px;\"><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-007 Coding for the TICKING state &nbsp; &nbsp; Coding for the TICKING state In the previous article, we added the Initial Transition Action. And now, in this article, let&#8217;s code for &#8216;Ticking&#8217;&nbsp; state. The purpose of the Ticking state is to show the current time or display the current time. &nbsp; Whenever the control [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8352,"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-8349","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>FSM Lecture 67: Exercise-007 Coding for the TICKING state<\/title>\n<meta name=\"description\" content=\"Exercise-007 Coding for the TICKING state. Display the current time in 24-hour and 12-hour formats using Arduino functions. Entry actions,\" \/>\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\/coding-for-the-ticking-state\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FSM Lecture 67: Exercise-007 Coding for the TICKING state\" \/>\n<meta property=\"og:description\" content=\"Exercise-007 Coding for the TICKING state. Display the current time in 24-hour and 12-hour formats using Arduino functions. Entry actions,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/\" \/>\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-03-12T04:09:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-24T04:52:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"578\" \/>\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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"FSM Lecture 67: Exercise-007 Coding for the TICKING state\",\"datePublished\":\"2022-03-12T04:09:26+00:00\",\"dateModified\":\"2023-08-24T04:52:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/\"},\"wordCount\":1137,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-1-24.png\",\"keywords\":[\"Finite state Machine(FSM)\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/\",\"name\":\"FSM Lecture 67: Exercise-007 Coding for the TICKING state\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-1-24.png\",\"datePublished\":\"2022-03-12T04:09:26+00:00\",\"dateModified\":\"2023-08-24T04:52:10+00:00\",\"description\":\"Exercise-007 Coding for the TICKING state. Display the current time in 24-hour and 12-hour formats using Arduino functions. Entry actions,\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-1-24.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-1-24.png\",\"width\":1280,\"height\":578,\"caption\":\"Figure 1. Ticking state\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-for-the-ticking-state\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FSM Lecture 67: Exercise-007 Coding for the TICKING state\"}]},{\"@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":"FSM Lecture 67: Exercise-007 Coding for the TICKING state","description":"Exercise-007 Coding for the TICKING state. Display the current time in 24-hour and 12-hour formats using Arduino functions. Entry actions,","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\/coding-for-the-ticking-state\/","og_locale":"en_US","og_type":"article","og_title":"FSM Lecture 67: Exercise-007 Coding for the TICKING state","og_description":"Exercise-007 Coding for the TICKING state. Display the current time in 24-hour and 12-hour formats using Arduino functions. Entry actions,","og_url":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-03-12T04:09:26+00:00","article_modified_time":"2023-08-24T04:52:10+00:00","og_image":[{"width":1280,"height":578,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24.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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"FSM Lecture 67: Exercise-007 Coding for the TICKING state","datePublished":"2022-03-12T04:09:26+00:00","dateModified":"2023-08-24T04:52:10+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/"},"wordCount":1137,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24.png","keywords":["Finite state Machine(FSM)"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/","url":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/","name":"FSM Lecture 67: Exercise-007 Coding for the TICKING state","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24.png","datePublished":"2022-03-12T04:09:26+00:00","dateModified":"2023-08-24T04:52:10+00:00","description":"Exercise-007 Coding for the TICKING state. Display the current time in 24-hour and 12-hour formats using Arduino functions. Entry actions,","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-24.png","width":1280,"height":578,"caption":"Figure 1. Ticking state"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/coding-for-the-ticking-state\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FSM Lecture 67: Exercise-007 Coding for the TICKING state"}]},{"@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\/8349","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=8349"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/8349\/revisions"}],"predecessor-version":[{"id":12934,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/8349\/revisions\/12934"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/8352"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=8349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=8349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=8349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}