{"id":7528,"date":"2025-03-22T17:23:35","date_gmt":"2025-03-22T08:23:35","guid":{"rendered":"https:\/\/robot.e-nat.org\/?p=7528"},"modified":"2025-03-24T12:11:08","modified_gmt":"2025-03-24T03:11:08","slug":"python%e5%85%a5%e9%96%80%e7%ac%ac1%e5%9b%9e%e3%80%8c%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0%e3%81%ae%e6%a7%8b%e6%88%90%e6%96%b9%e6%b3%95%e3%80%8d","status":"publish","type":"post","link":"https:\/\/robot.e-nat.org\/?p=7528","title":{"rendered":"Python\u5165\u9580\u7b2c1\u56de\u300c\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u69cb\u6210\u65b9\u6cd5\u300d"},"content":{"rendered":"\n<p>\u3000\u91d1\u5b8f\u548c\u5be6\u3067\u3059\u30022025\u5e74\u5ea6\u306e\u8b1b\u7fd2\u4f1a\u3067Spike3\u30a2\u30d7\u30ea\u3067Python\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u59cb\u3081\u3066\u307f\u305f\u3044\u4eba\u5411\u3051\u306b\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u884c\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u305f\u3060\u3057\u52d8\u9055\u3044\u3057\u306a\u3044\u3067\u307b\u3057\u3044\u306e\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306bPython\u3092\u9078\u3093\u3060\u304b\u3089\u3068\u3044\u3063\u3066\u3001\u3053\u308c\u307e\u3067\u306b\u6bd4\u3079\u3066\u660e\u3089\u304b\u306b\u30ed\u30dc\u30c3\u30c8\u306e\u52d5\u304d\u304c\u826f\u304f\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u306a\u305c\u304b\u3068\u8a00\u3046\u3068\u3001Spike3\u30a2\u30d7\u30ea\u3067\u306f\u307f\u306a\u3055\u3093\u304c\u3053\u308c\u307e\u3067\u4f7f\u3063\u3066\u3044\u308b\u30ef\u30fc\u30c9\u30d6\u30ed\u30c3\u30af\u3068Python\u3067\u300c\u3067\u304d\u308b\u3053\u3068\u300d\u306b\u3042\u307e\u308a\u5dee\u304c\u306a\u3044\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u308f\u305f\u3057\u306f\u611f\u3058\u3066\u3044\u308b\u304b\u3089\u3067\u3059\u3002<br>\u3000\u3053\u308c\u306f\u3001\u305d\u308c\u3067\u3082Python\u3067\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u3088\u3046\u3068\u601d\u3046\u4eba\u5411\u3051\u306e\u30c6\u30ad\u30b9\u30c8\u3067\u3059\u3002Python\u306e\u30b3\u30fc\u30c9\u306b\u6163\u308c\u3066\u304f\u308c\u3070\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u52b9\u7387\u306f\u30ef\u30fc\u30c9\u30d6\u30ed\u30c3\u30af\u3067\u4f5c\u6210\u3059\u308b\u3088\u308a\u306f\u9ad8\u3044\u3068\u3044\u3046\u3053\u3068\u306f\u9593\u9055\u3044\u306a\u3044\u3068\u8a00\u3048\u307e\u3059\u3002<br>\u3000\u307e\u305a\u3001\u4eca\u56de\u306fPython\u5165\u9580\u306e\u7b2c1\u56de\u3068\u3057\u3066\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u69cb\u6210\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<br>\u56db\u89d2\u5f62\u3092\u63cf\u304f\u3088\u3046\u306b\u52d5\u304f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u3001Python\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u66f8\u304d\u65b9\u3001\u3064\u307e\u308a\u304a\u4f5c\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u307e\u305a\u5fc5\u8981\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002\nimport motor_pair\nfrom hub import port\nimport time\n\n#\u521d\u671f\u5316\u51e6\u7406\nmotor_pair.pair(motor_pair.PAIR_1, port.C, port.D)\n\n#\u7e70\u308a\u8fd4\u3057\u547c\u3073\u51fa\u3059\u51e6\u7406\u306f\u95a2\u6570\u306b\u3057\u307e\u3057\u3087\u3046\u3002\ndef straight_turn(t1,t2):\n    motor_pair.move_tank(motor_pair.PAIR_1, 500, 500)\n    time.sleep_ms(t1) \n    motor_pair.move_tank(motor_pair.PAIR_1, 0, 500)\n    time.sleep_ms(t2)\n\n\n#main\uff08\u30e1\u30a4\u30f3\uff09\u95a2\u6570\u306f\u5fc5\u305a\u4f5c\u308a\u307e\u3057\u3087\u3046\u3002\ndef main():\n    #\u95a2\u6570\u306e\u4e2d\u3067\u306f\u3001tab\u30ad\u30fc\u3067\u5b57\u4e0b\u3052\u3057\u307e\u3059\u3002\n    for _ in range(4):\n        straight_turn(1000,800)\n\n    motor_pair.stop(motor_pair.PAIR_1)\n\n#\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u6700\u5f8c\u3067main\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002\nmain()<\/code><\/pre>\n\n\n\n<p>\u3000\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5927\u307e\u304b\u306a\u8aac\u660e\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u4e2d\u306e#\u3067\u59cb\u307e\u308b\u884c\u306b\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u3002\u3053\u306e#\u3067\u59cb\u307e\u308b\u884c\u306e\u3053\u3068\u3092\u30b3\u30e1\u30f3\u30c8\u884c\u3068\u8a00\u3044\u307e\u3059\u3002\u307f\u306a\u3055\u3093\u304c\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308b\u3068\u304d\u3082\u3001\u3053\u3053\u3067\u4f55\u3092\u3057\u3066\u3044\u308b\u304b\u308f\u304b\u308b\u3088\u3046\u306b\u30b3\u30e1\u30f3\u30c8\u884c\u3092\u66f8\u304d\u307e\u3057\u3087\u3046\u3002<br>\u3000\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u6700\u521d\u306b\u306fimport\uff08\u30a4\u30f3\u30dd\u30fc\u30c8\uff09\u6587\u3092\u66f8\u304d\u307e\u3059\u3002import\u306f\u3053\u308c\u304b\u3089\u4f5c\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u4f7f\u3046\u30e2\u30b8\u30e5\u30fc\u30eb\uff08\u90e8\u54c1\uff09\u3092\u8aad\u307f\u8fbc\u3080\u51e6\u7406\u3067\u3059\u3002<br>\u3000\u6b21\u306b\u521d\u671f\u5316\u51e6\u7406\u3092\u66f8\u304d\u307e\u3059\u3002motor_pair.pair()\u3067\u4e8c\u3064\u30e2\u30fc\u30bf\u30fc\u3092\u30da\u30a2\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u3064\u307e\u308a\u30bf\u30f3\u30af\u306e\u3088\u3046\u306a\u30ed\u30dc\u30c3\u30c8\u306e\u5de6\u306e\u30e2\u30fc\u30bf\u30fc(C)\u3068\u53f3\u306e\u30e2\u30fc\u30bf\u30fc(D)\u3092\u8a2d\u5b9a\u3059\u308b\u51e6\u7406\u3067\u3059\u3002<br>\u3000def\u3067\u59cb\u307e\u308b\u884c\u304c\u95a2\u6570\u5b9a\u7fa9\u3067\u3059\u3002\u7e70\u308a\u8fd4\u3057\u5b9f\u884c\u3059\u308b\u51e6\u7406\u306f\u95a2\u6570\u306b\u3057\u307e\u3059\u3002\u95a2\u6570\u306f\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002straight_turn\u95a2\u6570\u306e\u5f15\u6570\u306ft1\u3068t2\u306e\u4e8c\u3064\u3067t1\u306f\u307e\u3063\u3059\u3050\u9032\u3080\u6642\u9593\uff08\u30df\u30ea\u79d2\uff09\u3067\u3001t2\u306f\u53f3\u306b\u66f2\u304c\u308b\u6642\u9593\uff08\u30df\u30ea\u79d2\uff09\u3067\u3059\u3002\u95a2\u6570\u306e\u4e2d\u306e\u305d\u308c\u305e\u308c\u306e\u30b3\u30fc\u30c9\u306fSpike3\u30a2\u30d7\u30ea\u306e\u30ca\u30ec\u30c3\u30b8\u30d9\u30fc\u30b9\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u95a2\u6570\u306e\u4e2d\u306e\u30b3\u30fc\u30c9\u306fTab\u30ad\u30fc\u3067\u5b57\u4e0b\u3052\uff08\u30a4\u30f3\u30c7\u30f3\u30c8\uff09\u3057\u307e\u3059\u3002\u3053\u308c\u306fPython\u306e\u6c7a\u307e\u308a\u4e8b\u3067\u3059\u3002<br>\u3000Python\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306fmain\u95a2\u6570\u3092\u5fc5\u305a\u4e00\u3064\u4f5c\u6210\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u305d\u3057\u3066main\u95a2\u6570\u306e\u4e2d\u306b\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u3042\u3089\u3059\u3058\u3092\u66f8\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u306ffor _ in range(4)\u53e5\u3067straight_turn\u95a2\u6570\u30924\u56de\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u30021000,800\u304c\u5f15\u6570t1\u3001t2\u306b\u6e21\u3059\u5024\u3067\u3059\u3002for _ in range(4)\u53e5\u306f\u5c11\u3057\u96e3\u3057\u3044\u3067\u3059\u306d\u3002\u3053\u3053\u306b\u6307\u5b9a\u3057\u305f\u56de\u6570(4)\u5206straight_turn\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3060\u304b\u3089\u3001\u30ed\u30dc\u30c3\u30c8\u306f\u56db\u89d2\u3092\u63cf\u304f\u3088\u3046\u306b\u8d70\u308b\u308f\u3051\u3067\u3059\u3002for\u6587\u306e\u4e2d\u3082Tab\u30ad\u30fc\u3067\u30a4\u30f3\u30c7\u30f3\u30c8\u3057\u307e\u3059\u3002<br>\u3000motor_pair.stop(motor_pair.PAIR_1)\u3067\u30ed\u30dc\u30c3\u30c8\u3092\u505c\u6b62\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u305d\u3057\u3066\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u6700\u5f8c\u3067main()\u3068\u3057\u3066main\u95a2\u6570\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u3053\u308c\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u5b9f\u884c\u3055\u308c\u308b\u308f\u3051\u3067\u3059\u3002\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306b\u3088\u3063\u3066\u306fmain\u95a2\u6570\u304c\u81ea\u52d5\u7684\u306b\u5b9f\u884c\u3055\u308c\u308b\u3082\u306e\u3082\u3042\u308b\u306e\u3067\u3059\u304c\u3001Python\u306e\u5834\u5408\u306f\u81ea\u5206\u3067main\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br>\u3000\u3053\u308c\u304c\u3001Python\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u57fa\u672c\u306e\u5f62\u3067\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u91d1\u5b8f\u548c\u5be6\u3067\u3059\u30022025\u5e74\u5ea6\u306e\u8b1b\u7fd2\u4f1a\u3067Spike3\u30a2\u30d7\u30ea\u3067Python\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u59cb\u3081\u3066\u307f\u305f\u3044\u4eba\u5411\u3051\u306b\u8a18\u4e8b &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,26,15,14],"class_list":["post-7528","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-2","tag-education","tag-15","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\/7528","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=7528"}],"version-history":[{"count":11,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/posts\/7528\/revisions"}],"predecessor-version":[{"id":7541,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=\/wp\/v2\/posts\/7528\/revisions\/7541"}],"wp:attachment":[{"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robot.e-nat.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}