{"id":7186,"date":"2022-02-07T08:52:30","date_gmt":"2022-02-07T08:52:30","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=7186"},"modified":"2023-08-08T16:12:54","modified_gmt":"2023-08-08T10:42:54","slug":"exercise-003-dispatching-time-tick-event","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/","title":{"rendered":"FSM Lecture 28- Exercise-003 Dispatching time tick event"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 50px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><strong>Exercise-003 Dispatching time tick event<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"border-width: 0px; font-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;\"><span style=\"font-weight: 400;\">In the <a href=\"http:\/\/fastbitlab.com\/exercise-003-implementing-event-producer-code\/\" target=\"_blank\" rel=\"noopener\">previous article<\/a>, we implemented the code to dispatch the user event. <\/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;\"><span style=\"font-weight: 400;\">Let\u2019s write a small code to dispatch the time tick event. For that, we will use the <\/span><b>millis()<\/b><span style=\"font-weight: 400;\"> function provided by the Arduino framework.<\/span><\/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=\"text-decoration: underline; color: #000000;\"><b>millis()<\/b><\/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;\">It returns the number of milliseconds passed since the Arduino board began running the current program. This number will overflow(go back to 0), after approximately 50 days. Because its datatype is unsigned long, the width is 4 bytes.&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=\"color: #000000;\"><span style=\"text-decoration: underline; color: #000080;\"><span style=\"font-weight: 400;\">Syntax<\/span><\/span><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline; color: #000080;\">: <\/span>time=millis()<\/span><\/span><\/p>\n<figure id=\"attachment_7189\" aria-describedby=\"caption-attachment-7189\" style=\"width: 1505px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-7189\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Example-code.png\" alt=\"Figure 1. Example code\" width=\"1505\" height=\"529\"><figcaption id=\"caption-attachment-7189\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Example code<\/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;\">Here, they have used <\/span><b>millis()<\/b><span style=\"font-weight: 400;\">. And in this code statement: <\/span><b>myTime = millis()<\/b><span style=\"font-weight: 400;\">, they are storing the current time into the <\/span><b>myTime<\/b><span style=\"font-weight: 400;\"> variable. The current time is not the clock time; it is the number of milliseconds passed since the Arduino board began running the program. That means a number of milliseconds passed before executing this statement. So, that value is stored in <\/span><b>myTime<\/b><span style=\"font-weight: 400;\">, and we will use millis() function.&nbsp;<\/span><\/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;\">In our project, the fourth task is, &#8216;Dispatch the time tick event for every 100 milliseconds&#8217;. Because that\u2019s what we decided to do, our state machine receives the time tick event for every 100 milliseconds.<\/span><\/p>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<figure id=\"attachment_7193\" aria-describedby=\"caption-attachment-7193\" style=\"width: 1025px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-7193\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/loop-function.png\" alt=\"Figure 2. Loop function\" width=\"1025\" height=\"599\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function.png 1025w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-300x175.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-768x449.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-1024x598.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-600x351.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-120x70.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-500x292.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-200x117.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-400x234.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/loop-function-800x468.png 800w\" sizes=\"(max-width: 1025px) 100vw, 1025px\" \/><figcaption id=\"caption-attachment-7193\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Loop function<\/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;\"><span style=\"font-weight: 400;\">I will create one local static variable in the loop function. <\/span><b>current_time \u2013<\/b><span style=\"font-weight: 400;\"> this is to store the current time; This returns the saved current time. Its data type is uint32_t, and initially, I will store the current time using the <\/span><b>millis()<\/b><span style=\"font-weight: 400;\"> functions.&nbsp; Since it is a static variable, the first time when the control reaches this loop, only one time this variable will be initialized to the current_time. That is, in terms of the number of milliseconds.&nbsp;<\/span><\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\"><span style=\"color: #008000;\">\/\/4. dispatch the time tick event for every 100ms<\/span>\r\n<span style=\"color: #ff99cc;\">if<\/span>(millis() - current_time &gt;= 100){\r\n  <span style=\"color: #008000;\">\/\/100ms has passed<\/span>\r\n  current_time = millis();\r\n  te.super.sig = TIME_TICK;\r\n  <span style=\"color: #ff99cc;\">if<\/span>(++te.ss &gt; 10) te.ss = 1;\r\n  protimer_event_dispatcher(&amp;protimer,&amp;te.super);\r\n}<\/pre>\n<p class=\"\" style=\"text-align: center;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">Dispatch the Time tick event function 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;\"><span style=\"font-weight: 400;\">After that, I will write one small logic. if(millis() &#8211; current_time &gt;= 100). This <\/span><b>millis()<\/b><span style=\"font-weight: 400;\"> function is the actual running current_time, minus the saved current_time. If this difference is equal to or grows bigger than 100 milliseconds, that means 100 milliseconds has passed.<\/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=\"font-weight: 400; color: #000000;\">In that case, what should we do? We should first reset this current_time because, for the next event generation, we have to reset this with millis(). I\u2019m just resetting this variable with the current time. Because, current_time = millis() code in loop function will not execute for every loop, so because it\u2019s a static variable. That\u2019s why I am again initializing it.&nbsp;<\/span><\/p>\n<figure id=\"attachment_7190\" aria-describedby=\"caption-attachment-7190\" style=\"width: 1079px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-7190 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Loop-1.png\" alt=\"Exercise-003 Dispatching time tick event\" width=\"1079\" height=\"537\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1.png 1079w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-300x149.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-768x382.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-1024x510.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-600x299.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-120x60.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-500x249.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-200x100.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-400x199.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Loop-1-800x398.png 800w\" sizes=\"(max-width: 1079px) 100vw, 1079px\" \/><figcaption id=\"caption-attachment-7190\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Loop function<\/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;\">Let\u2019s create one variable. Protimer_tick_event t te = {.ss = 0}; The \u2018ss\u2019 field, that is = 0. Because we have to use the sub-second field.&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, we have to make an event te.super.sig = TIME_TICK; ++te.ss; Whenever 100 milliseconds have passed, we have to increment this. Its value varies from 1 to 10. That&#8217;s why, if te.ss grows bigger than 10, then we have to reset te.ss to 1. Or you can do if(++te.ss &gt; 10) te.ss = 1). That means &#8216;te&#8217; has to be the static variable because it can&#8217;t be a local variable. Otherwise, for every loop, this will be initialized to 0. When it becomes 11, it resets to 1.&nbsp; After that, we have to call the event_dipatcher te.super. That\u2019s about dispatching the time tick event to the state machine.<\/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 you can also do this using a timer interrupt for every 100 milliseconds, you can generate a timer interrupt, and you can also do 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;\">In the upcoming article, let\u2019s understand the<span style=\"color: #ff6600;\"><a style=\"color: #ff6600;\" href=\"http:\/\/fastbitlab.com\/fsm-lecture-29-button-bouncing-explanation\/\" target=\"_blank\" rel=\"noopener\"> button bouncing<\/a><\/span>, and we will try to implement this.&nbsp;<\/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=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px;\"><span style=\"color: #000000;\">Click here: <\/span><span style=\"color: #3366ff;\"><a style=\"color: #3366ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #3366ff;\">https:\/\/fastbitlab.com\/course1&nbsp;<\/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-003 Dispatching time tick event &nbsp; &nbsp; In the previous article, we implemented the code to dispatch the user event. Let\u2019s write a small code to dispatch the time tick event. For that, we will use the millis() function provided by the Arduino framework. &nbsp; millis() It returns the number of milliseconds passed since [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7189,"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-7186","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 28- Exercise-003 Dispatching time tick event<\/title>\n<meta name=\"description\" content=\"Exercise-003 Dispatching time tick event. In the previous article, we implemented the code to dispatch the user event. Let\u2019s write a small\" \/>\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-003-dispatching-time-tick-event\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FSM Lecture 28- Exercise-003 Dispatching time tick event\" \/>\n<meta property=\"og:description\" content=\"Exercise-003 Dispatching time tick event. In the previous article, we implemented the code to dispatch the user event. Let\u2019s write a small\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/\" \/>\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-02-07T08:52:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-08T10:42:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Example-code-e1644224157196.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1505\" \/>\n\t<meta property=\"og:image:height\" content=\"529\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"FSM Lecture 28- Exercise-003 Dispatching time tick event\",\"datePublished\":\"2022-02-07T08:52:30+00:00\",\"dateModified\":\"2023-08-08T10:42:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/\"},\"wordCount\":628,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Example-code-e1644224157196.png\",\"keywords\":[\"Finite state Machine(FSM)\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/\",\"name\":\"FSM Lecture 28- Exercise-003 Dispatching time tick event\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Example-code-e1644224157196.png\",\"datePublished\":\"2022-02-07T08:52:30+00:00\",\"dateModified\":\"2023-08-08T10:42:54+00:00\",\"description\":\"Exercise-003 Dispatching time tick event. In the previous article, we implemented the code to dispatch the user event. Let\u2019s write a small\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Example-code-e1644224157196.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Example-code-e1644224157196.png\",\"width\":1505,\"height\":529,\"caption\":\"Figure 1. Example code\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/exercise-003-dispatching-time-tick-event\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FSM Lecture 28- Exercise-003 Dispatching time tick event\"}]},{\"@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 28- Exercise-003 Dispatching time tick event","description":"Exercise-003 Dispatching time tick event. In the previous article, we implemented the code to dispatch the user event. Let\u2019s write a small","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-003-dispatching-time-tick-event\/","og_locale":"en_US","og_type":"article","og_title":"FSM Lecture 28- Exercise-003 Dispatching time tick event","og_description":"Exercise-003 Dispatching time tick event. In the previous article, we implemented the code to dispatch the user event. Let\u2019s write a small","og_url":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-02-07T08:52:30+00:00","article_modified_time":"2023-08-08T10:42:54+00:00","og_image":[{"width":1505,"height":529,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Example-code-e1644224157196.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"FSM Lecture 28- Exercise-003 Dispatching time tick event","datePublished":"2022-02-07T08:52:30+00:00","dateModified":"2023-08-08T10:42:54+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/"},"wordCount":628,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Example-code-e1644224157196.png","keywords":["Finite state Machine(FSM)"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/","url":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/","name":"FSM Lecture 28- Exercise-003 Dispatching time tick event","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Example-code-e1644224157196.png","datePublished":"2022-02-07T08:52:30+00:00","dateModified":"2023-08-08T10:42:54+00:00","description":"Exercise-003 Dispatching time tick event. In the previous article, we implemented the code to dispatch the user event. Let\u2019s write a small","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Example-code-e1644224157196.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Example-code-e1644224157196.png","width":1505,"height":529,"caption":"Figure 1. Example code"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/exercise-003-dispatching-time-tick-event\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FSM Lecture 28- Exercise-003 Dispatching time tick event"}]},{"@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\/7186","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=7186"}],"version-history":[{"count":4,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7186\/revisions"}],"predecessor-version":[{"id":15338,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7186\/revisions\/15338"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/7189"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=7186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=7186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=7186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}