{"id":1712,"date":"2021-01-27T08:06:10","date_gmt":"2021-01-27T08:06:10","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1712"},"modified":"2021-01-27T08:39:15","modified_gmt":"2021-01-27T08:39:15","slug":"charlie-drums","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2021\/charlie-drums","title":{"rendered":"Charlie drums"},"content":{"rendered":"\n<p>A slow drummer but nevertheless he drums:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Charlie playing MIDI Drum v0.1\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/CEdTk83Oux0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>but making he move an arm in just 2 simples steps was frustrating&#8230; spent a whole night fiddling with micropython &#8216;mindstorms&#8217; library&#8230; sending script with &#8216;ampy&#8217; gave stupid errors (like  &#8216;RuntimeError: There is not a motor connected to port B.&#8217;) or even worst leading to firmware crashing so badly that I had to take the battery out of Charlie&#8217;s head at least 5 times.<\/p>\n\n\n\n<p>So I gave up trying to use something not documented at all and reached for help from a great ROBOTMAK3R:   <a href=\"https:\/\/hubmodule.readthedocs.io\/en\/latest\/\" data-type=\"URL\" data-id=\"https:\/\/hubmodule.readthedocs.io\/en\/latest\/\">Nard Strijbosch&#8217;s Unofficial LEGO MINDSTORMS and SPIKE Prime low-level hub module documentation<\/a><\/p>\n\n\n\n<p>So instead of using &#8216;mindstorms.Motor&#8217; I used &#8216;hub.port&#8217; own motor class:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">leftArm = port.B.motor\nleftArm.run_for_degrees(10, speed=-100)\n while leftArm.busy(1):\n     pass\n leftArm.run_for_degrees(10, speed=100)\n while leftArm.busy(1):\n     pass<\/pre>\n\n\n\n<p>and now everytime I run a script through &#8216;ampy&#8217; it works &#8211; except on first time after powering on Charlie&#8217; &#8211; it seems I have to first access REPL and only after exiting it accepts &#8216;ampy run&#8217; commands &#8211; if I forget to do that, Charlie turns itself off.<\/p>\n\n\n\n<p>I am a bit disappointed with motor speed. After using the Charlie activity from the App (scratch based) I was expecting faster movements with micropython:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"LEGO 51515 Charlie\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/8JEWWWXpfrA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>I need to look into the scratch demo&#8230; but I only managed to use it on my phone (on my tablet the App doesn&#8217;t load any activity) and coding is terrible on a small screen (not to mention debugging!!!).<\/p>\n\n\n\n<p>I am not enjoying this new &#8220;paradigm&#8221;. Maybe the future is Apps and smart devices but I like to think that I can choose my own future. Can&#8217;t wait to see Pybricks running on this.<\/p>\n\n\n\n<p>&#8211;edited&#8211;<\/p>\n\n\n\n<p>the scratch demo controls the motors through speed only, not through position. I feel cheated \ud83d\ude00<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A slow drummer but nevertheless he drums: but making he move an arm in just 2 simples steps was frustrating&#8230; spent a whole night fiddling with micropython &#8216;mindstorms&#8217; library&#8230; sending script with &#8216;ampy&#8217; gave stupid errors (like &#8216;RuntimeError: There is not a motor connected to port B.&#8217;) or even worst leading to firmware crashing so &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2021\/charlie-drums\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;Charlie drums&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[],"series":[],"class_list":["post-1712","post","type-post","status-publish","format-standard","hentry","category-sem-categoria"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-rC","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1712"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1712\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1712"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}