{"id":814,"date":"2014-11-16T01:10:11","date_gmt":"2014-11-16T01:10:11","guid":{"rendered":"http:\/\/ofalcao.pt\/blog\/?p=814"},"modified":"2016-06-14T15:31:02","modified_gmt":"2016-06-14T14:31:02","slug":"ir-remote-control-speed-and-position","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2014\/ir-remote-control-speed-and-position","title":{"rendered":"IR remote control &#8211; speed and position"},"content":{"rendered":"<p>iConor&#8217;s second LIRC configuration file,<a href=\"http:\/\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/11\/Combo_PWM.conf_1.zip\">Combo_PWM.conf<\/a>, allows us to use LIRC command &#8216;irsend&#8217; to control the speed of a LEGO Power Functions Motor or the position of a LEGO Power Functions Servo Motor much like the 8879 IR Speed Remote Control.<\/p>\n<div class=\"jetpack-video-wrapper\"><iframe loading=\"lazy\" title=\"Programmatically control LEGO PF Motors speed or position\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/6HsJntirn3Y?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><\/div>\n<p>This shell script sends a sequence of 7 increasingly values then returns to zero and repeat it in the opposite direction:<\/p>\n<pre>#!\/bin\/bash\r\n#0\r\nirsend SEND_ONCE LEGO_Combo_PWM 400B ; sleep\u00a0 1.2\r\n#1\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 401A ; sleep\u00a0 1.2\r\n#2\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 4029 ; sleep\u00a0 1.2\r\n#3\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 4038 ; sleep\u00a0 1.2\r\n#4\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 404F ; sleep\u00a0 1.2\r\n#5\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 405E ; sleep\u00a0 1.2\r\n#6\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 406D ; sleep\u00a0 1.2\r\n#7\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 407C ; sleep\u00a0 1.2\r\n#0\r\nirsend SEND_ONCE LEGO_Combo_PWM 4083 ; sleep\u00a0 1.2\r\n#-1\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 40F4 ; sleep\u00a0 1.2\r\n#-2\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 40E5 ; sleep\u00a0 1.2\r\n#-3\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 40D6 ; sleep\u00a0 1.2\r\n#-4\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 40C7 ; sleep\u00a0 1.2\r\n#-5\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 40B0 ; sleep\u00a0 1.2\r\n#-6\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 40A1 ; sleep\u00a0 1.2\r\n#-7\/7\r\nirsend SEND_ONCE LEGO_Combo_PWM 4092 ; sleep\u00a0 1.2<\/pre>\n<p>There is a total of 256 key codes in the configuration file (16 different values for the red plug x 16 different values for the blue plug). I used just the first subset of 16 so the first byte (for the blue plug) is always &#8217;40&#8217; but it doesn&#8217;t matter because I connected both Servo and M-motor to the red plug .<\/p>\n<p>The sequence of key codes is not exactly the same as in the configuration file &#8211; I reordered the last 7 key codes.<\/p>\n<p>The &#8216;sleep 1.2&#8217;\u00a0 makes the script wait 1.2 seconds between each command. It is more or less the time the IR keeps the command active (bigger values would make the Servo return to center and the M-motor stop).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>iConor&#8217;s second LIRC configuration file,Combo_PWM.conf, allows us to use LIRC command &#8216;irsend&#8217; to control the speed of a LEGO Power Functions Motor or the position of a LEGO Power Functions Servo Motor much like the 8879 IR Speed Remote Control. This shell script sends a sequence of 7 increasingly values then returns to zero and &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2014\/ir-remote-control-speed-and-position\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;IR remote control &#8211; speed and position&#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":[239,241,255,86,257,259,136,261,263],"series":[],"class_list":["post-814","post","type-post","status-publish","format-standard","hentry","category-sem-categoria","tag-infrared-pt","tag-ir-pt","tag-lirc-pt","tag-motor","tag-position-pt","tag-program-pt","tag-remote-control","tag-servo-pt","tag-speed-pt"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-d8","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/814","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=814"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/814\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=814"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}