{"id":7550,"date":"2025-04-19T17:11:07","date_gmt":"2025-04-19T08:11:07","guid":{"rendered":"https:\/\/robot.e-nat.org\/?p=7550"},"modified":"2025-04-19T17:18:43","modified_gmt":"2025-04-19T08:18:43","slug":"python%e5%85%a5%e9%96%80%e7%ac%ac3%e5%9b%9e%e3%80%8c%e5%9f%ba%e6%9c%ac%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%b3%e3%83%88%e3%83%ac%e3%83%bc%e3%82%b9%e3%80%8d","status":"publish","type":"post","link":"https:\/\/robot.e-nat.org\/?p=7550","title":{"rendered":"Python\u5165\u9580\u7b2c3\u56de\u300c\u57fa\u672c\u306e\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u300d"},"content":{"rendered":"\n<p>\u3000\u91d1\u5b8f\u548c\u5be6\u3067\u3059\u3002Python\u5165\u9580\u306e\u7b2c3\u56de\u3067\u3059\u3002\u4eca\u56de\u306f\u3001\u57fa\u672c\u306e\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u3067\u3059\u3002\u9ed2\u3044\u3068\u3053\u308d\u306e\u4e0a\u306b\u3044\u308b\u3068\u53f3\u306b\u9032\u3082\u3046\u3068\u3057\u3066\u3001\u767d\u3044\u3068\u3053\u308d\u306b\u3044\u308b\u3068\u5de6\u306b\u9032\u3082\u3046\u3068\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u9ed2\u3044\u7dda\u3092\u305f\u3069\u308a\u307e\u3059\u3002<br>\u3000\u30e2\u30fc\u30bf\u30fc\u306fC\u30dd\u30fc\u30c8\u3068D\u30dd\u30fc\u30c8\u306b\u63a5\u7d9a\u3055\u308c\u3066\u304a\u308a\u3001motor.pair.pair()\u95a2\u6570\u3067\u30da\u30a2\u306b\u3057\u3066\u30ed\u30dc\u30c3\u30c8\u3092\u52d5\u304b\u3057\u307e\u3059\u3002B\u30dd\u30fc\u30c8\u306b\u63a5\u7d9a\u3057\u305f\u30ab\u30e9\u30fc\u30bb\u30f3\u30b5\u30fc\u306e\u53cd\u5c04\u5149\u304c50\u672a\u6e80\u3060\u3068\u9ed2\u3044\u7dda\u4e0a\u306b\u3044\u308b\u3068\u5224\u65ad\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from hub import port\nimport motor_pair, color_sensor, runloop\n\nmotor_pair.pair(motor_pair.PAIR_1, port.C, port.D)\n\nasync def line_follow_forever():\n    while (True):\n        if (color_sensor.reflection(port.B) &lt; 50): # \u9ed2\u3044\u7dda\u306e\u4e0a\n            # \u30b9\u30c6\u30a2\u30ea\u30f3\u30b030\u3067\u53f3\u306b\n            motor_pair.move(motor_pair.PAIR_1, 30, velocity = 300)  \n        else: # \u767d\u3044\u3068\u3053\u308d\u306e\u4e0a\n            # \u30b9\u30c6\u30a2\u30ea\u30f3\u30b0-30\u3067\u5de6\u306b\n            motor_pair.move(motor_pair.PAIR_1, -30, velocity = 300)\n\nasync def main():\n    await line_follow_forever()\n\nrunloop.run(main())<\/code><\/pre>\n\n\n\n<p>\u3000motor_pair.move\u95a2\u6570\u306e\u7b2c\u4e8c\u5f15\u6570\u304csteering(\u30b9\u30c6\u30a2\u30ea\u30f3\u30b0\uff09\u3067\u3053\u306e\u30ed\u30dc\u30c3\u30c8\u306e\u5834\u5408\u300130\u3060\u3068\u53f3\u65b9\u5411\u3078-30\u3060\u3068\u5de6\u65b9\u5411\u306b\u9032\u3082\u3046\u3068\u3057\u307e\u3059\u3002\u7b2c\u4e09\u5f15\u6570velocity = 300\u306f\u901f\u5ea6\u3067\u3059\u3002<br>\u3000\u3053\u308c\u3067\u3001\u3044\u308f\u3086\u308b\u7247\u5074\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u91d1\u5b8f\u548c\u5be6\u3067\u3059\u3002Python\u5165\u9580\u306e\u7b2c3\u56de\u3067\u3059\u3002\u4eca\u56de\u306f\u3001\u57fa\u672c\u306e\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u3067\u3059\u3002\u9ed2\u3044\u3068\u3053\u308d\u306e\u4e0a\u306b\u3044\u308b\u3068\u53f3\u306b\u9032\u3082 &hellip; <\/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":""},"categories":[41],"tags":[43,21,15,22,14],"class_list":["post-7550","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-2","tag-mindstorms","tag-15","tag-22","tag-14","latest_post"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/posts\/7550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7550"}],"version-history":[{"count":4,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/posts\/7550\/revisions"}],"predecessor-version":[{"id":7554,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/posts\/7550\/revisions\/7554"}],"wp:attachment":[{"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}