{"id":1511,"date":"2016-12-06T16:06:12","date_gmt":"2016-12-07T00:06:12","guid":{"rendered":"http:\/\/appinventor.pevest.com\/?p=1511"},"modified":"2016-12-06T16:06:12","modified_gmt":"2016-12-07T00:06:12","slug":"using-the-pedometer-in-mit-app-inventor","status":"publish","type":"post","link":"https:\/\/coldstreams.com\/appinventor\/2016\/12\/06\/using-the-pedometer-in-mit-app-inventor\/","title":{"rendered":"Using the Pedometer in MIT App Inventor"},"content":{"rendered":"<p>The pedometer uses the phones motion sensors (accelerometers) to identify when the phone (or tablet) is being carried by someone that is walking &#8211; and uses this to measure the number of steps you take as you walk. When calibrated to the length of your stride, the pedometer provides a way to estimate the distance you have traveled.<\/p>\n<p>The pedometer is so simple to use, I put this example together while eating lunch today.<\/p>\n<h2>User Interface<\/h2>\n<p>This is a simple program!<\/p>\n<p>To use this app, enter your stride length in meters. For illustration, I set the stride length to 1\/2 meter or 0.5, as seen in this screen shot:<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Screenshot_20161206-153814.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1513\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Screenshot_20161206-153814-576x1024.png\" alt=\"Screenshot_20161206-153814\" width=\"311\" height=\"553\" \/><\/a><\/p>\n<p>Press the <em>Start measuring steps<\/em> button to activate the pedometer and then start walking with your phone. You will soon see the <em>Elapsed distance<\/em> value increase as you move around.<\/p>\n<h2>Designer View<\/h2>\n<p><!--more--><\/p>\n<p>Using the Designer, set a <em>Horizontal<\/em> layout at top, and add a <em>Label<\/em> and set its text to <em>Set stride length<\/em>:, then add a <em>Textbox<\/em> to its right.<\/p>\n<p>Add another <em>Horizontal<\/em> layout and add two buttons. Set one for the <em>Start measuring<\/em> button and the other for the <em>Stop measuring<\/em> button.<\/p>\n<p>The next line is optional &#8211; a label has been added which is used to display the <em>WalkingStep<\/em> event status.<\/p>\n<p>Then add another <em>Horizontal<\/em> layout with two labels &#8211; one to say &#8220;Elapsed distance:&#8221; and the second to display the distance traveled.<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Voila_Capture-2016-12-06_03-29-39_PM.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1515\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Voila_Capture-2016-12-06_03-29-39_PM.gif\" alt=\"Voila_Capture 2016-12-06_03-29-39_PM\" width=\"289\" height=\"497\" \/><\/a><\/p>\n<p>Don&#8217;t forget to add the <em>Pedometer<\/em> component! The <em>Pedometer<\/em> is located in the <em>Sensors<\/em> section of the <em>Palette<\/em>, and when dropped on the <em>Designer View<\/em>, appears as a non-visible component below the screen area.<\/p>\n<h3>Components<\/h3>\n<p>The components are labeled as shown here:<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Components.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1514\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Components.gif\" alt=\"Components\" width=\"220\" height=\"342\" \/><\/a><\/p>\n<p>The <em>NumbersOnly<\/em> property checkbox of <em>txtStrideLength<\/em> is checked to limit the input to numeric values.<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Properties.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1518\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Properties-236x1024.gif\" alt=\"Properties\" width=\"139\" height=\"603\" \/><\/a><\/p>\n<h2>Blocks View<\/h2>\n<p>Setting up the <em>Designer View<\/em> is harder than writing the app!<\/p>\n<p>The <em>Pedometer<\/em> is started by &#8211; surprise &#8211; calling its <em>.Start<\/em> method.<\/p>\n<p>The <em>Pedometer<\/em> is stopped by calling its .<em>Stop<\/em> method.<\/p>\n<p>The .<em>Reset<\/em> method resets the distance counters to zero.<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Blocks1.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1516\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Blocks1.gif\" alt=\"Blocks1\" width=\"628\" height=\"253\" \/><\/a><\/p>\n<p>As you walk, the <em>Pedometer<\/em> component generates two events &#8211; either <em>SingleStep<\/em> or <em>WalkStep<\/em>. The <em>distance<\/em> parameter holds the estimated distance traveled and is the same as the <em>Pedometer.Distance<\/em> property.<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Blocks2.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1517\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2016\/12\/Blocks2.gif\" alt=\"Blocks2\" width=\"541\" height=\"148\" \/><\/a><\/p>\n<h2>Source Download<\/h2>\n<p>Access the source file at <a href=\"http:\/\/ai2.appinventor.mit.edu\/?locale=en#4517706343383040\">the MIT App Inventory Gallery<\/a>.<\/p>\n<h2>E-Books<\/h2>\n<p>In addition to hundreds of posts and examples on this blog,\u00a0I have several e-books available from Google Books, Amazon and other outlets. The books cover topics that are far too large to cover in blog posts, especially for\u00a0<strong><em>Volume 3 &#8211; Databases and Files<\/em><\/strong> and <em><strong>Volume 4 &#8211; Graphics, Animation and Chart<\/strong><\/em><strong>s<\/strong>. Volumes 1 and 2 are intended for those just starting out with App Inventor.<\/p>\n<p>Visit <a href=\"http:\/\/appinventor.pevest.com\/?page_id=33\">the books page<\/a> for details on each book, sample chapters, where to buy &#8211; all are very inexpensive.<\/p>\n<p>Also, use the <em>Search<\/em> box in the left column of this web site to look for other examples to help you with your App Inventor programming!<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/07\/AppInventor-Vol1-RevisedCover.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-871 size-medium\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/07\/AppInventor-Vol1-RevisedCover-188x300.jpg\" alt=\"AppInventor-Vol1-RevisedCover\" width=\"188\" height=\"300\" \/><\/a><\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/07\/AppInventor-Vol2-CoverRevised.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-872 size-medium\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/07\/AppInventor-Vol2-CoverRevised-190x300.jpg\" alt=\"AppInventor-Vol2-CoverRevised\" width=\"190\" height=\"300\" \/><\/a><\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/08\/AI2Volume3Cover1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-859\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/08\/AI2Volume3Cover1-188x300.jpg\" alt=\"AI2Volume3Cover\" width=\"188\" height=\"300\" \/><\/a><\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/07\/CoverOnly2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1209\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/07\/CoverOnly2-195x300.png\" alt=\"CoverOnly2\" width=\"195\" height=\"300\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The pedometer uses the phones motion sensors (accelerometers) to identify when the phone (or tablet) is being carried by someone that is walking &#8211; and uses this to measure the number of steps you take as you walk. When calibrated to the length of your stride, the pedometer provides a way to estimate the distance &hellip; <a href=\"https:\/\/coldstreams.com\/appinventor\/2016\/12\/06\/using-the-pedometer-in-mit-app-inventor\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using the Pedometer in MIT App Inventor<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1517,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1511","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-components"],"_links":{"self":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts\/1511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/comments?post=1511"}],"version-history":[{"count":0,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts\/1511\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/media\/1517"}],"wp:attachment":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/media?parent=1511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/categories?post=1511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/tags?post=1511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}