{"id":1763,"date":"2023-06-03T20:39:54","date_gmt":"2023-06-03T11:39:54","guid":{"rendered":"https:\/\/www.rocher.kyoto.jp\/arbr\/?p=1763"},"modified":"2023-06-03T20:39:54","modified_gmt":"2023-06-03T11:39:54","slug":"%e3%82%b5%e3%83%bc%e3%83%9c%e3%83%a2%e3%83%bc%e3%82%bf%e3%83%bcsg90%e3%81%8c%e5%8d%8a%e5%88%86%e3%81%ae%e8%a7%92%e5%ba%a6%e3%81%97%e3%81%8b%e5%9b%9e%e3%82%89%e3%81%aa%e3%81%84%e3%81%ae%e3%81%a7","status":"publish","type":"post","link":"https:\/\/www.rocher.kyoto.jp\/arbr\/?p=1763","title":{"rendered":"\u30b5\u30fc\u30dc\u30e2\u30fc\u30bf\u30fcSG90\u304c\u534a\u5206\u306e\u89d2\u5ea6\u3057\u304b\u56de\u3089\u306a\u3044\u306e\u3067\u8abf\u67fb"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u74b0\u5883<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>VSCode<\/li>\n\n\n\n<li>PlatformIO<\/li>\n\n\n\n<li>ESP-WROOM-02(\u81ea\u4f5c\u57fa\u76e4)<\/li>\n\n\n\n<li>SG90(\u306eAliexpress\u3067\u8cb7\u3063\u305f\u4e92\u63db\u54c1\uff1f)<\/li>\n\n\n\n<li>Windows11<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8b\u8c61<\/h2>\n\n\n\n<p>SG90\u3092PlatformIO\u3067\u5165\u308c\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u30670,90,180\u5ea6\u3067\u52d5\u304b\u305d\u3046\u3068\u3057\u305f\u3068\u3053\u308d\u305d\u308c\u305e\u308c0,45,90\u5ea6\u3050\u3089\u3044\u3057\u304b\u52d5\u304b\u306a\u304b\u3063\u305f<\/p>\n\n\n\n<p>\u30bd\u30fc\u30b9\u306f\u4ee5\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;Arduino.h>\n#include &lt;Servo.h>\n\n\n#define SERVO_PIN   12\n\n\nServo servoMotor; \n\nvoid setup() {\n  Serial.begin(115200);\n  delay(100);\n  digitalWrite(LED_PIN, HIGH);\n  servoMotor.attach(SERVO_PIN);\n}\n\nint count = 0;\nint angle&#91;] = {0,90,180};\nvoid loop() {\n  \n  servoMotor.write(angle&#91;count%3]);\n\n  Serial.printf(\"%s - run %d %d \\n\",__func__,count,servoMotor.readMicroseconds());\n  count++;\n  delay(1000);\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;env:esp_wroom_02]\r\nplatform = espressif8266\r\nboard = esp_wroom_02\r\nframework = arduino\r\nmonitor_speed = 115200\r\nupload_port = COM9<\/code><\/pre>\n\n\n\n<p>servoMotor.readMicroseconds()\u3067\u307f\u3066\u307f\u308b\u3068\u672c\u6765500,1450,2400(ms)\u3050\u3089\u3044\u3067\u3042\u3063\u3066\u307b\u3057\u3044\u6570\u5024\u304c1000,1500,2000\u3050\u3089\u3044\u306b\u306a\u3063\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5bfe\u5fdc<\/h2>\n\n\n\n<p>\u30b5\u30fc\u30dc\u30e2\u30fc\u30bf\u30fc\u306e\u521d\u671f\u5316\u3092\u3059\u308b\u3068\u304d\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u660e\u793a\u7684\u306b0\u5ea6\u3068180\u5ea6\uff08<a href=\"https:\/\/akizukidenshi.com\/download\/ds\/towerpro\/SG90_a.pdf\">\u30c7\u30fc\u30bf\u30b7\u30fc\u30c8<\/a>\u7684\u306b\u306f-90\u5ea6\u306890\u5ea6\uff09\u306e\u5024\u3092\u6307\u5b9a\u3057\u3066\u3084\u3063\u305f\u3089\u52d5\u3044\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>servoMotor.attach(SERVO_PIN,500,2400);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u539f\u56e0<\/h2>\n\n\n\n<p>PlatformIO\u3060\u3068platform \u3092\u5207\u308a\u66ff\u3048\u308b\u3068\u305d\u308c\u305e\u308c\u306e\u30de\u30a4\u30b3\u30f3\u306b\u5fdc\u3058\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b\u307f\u305f\u3044\u3002\u305d\u3057\u3066\u305d\u3053(Servo.h)\u306b\u3042\u308b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u6b32\u3057\u3044\u5024\u3058\u3083\u306a\u304b\u3063\u305f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define DEFAULT_MIN_PULSE_WIDTH      1000 \/\/ uncalibrated default, the shortest duty cycle sent to a servo\r\n#define DEFAULT_MAX_PULSE_WIDTH      2000 \/\/ uncalibrated default, the longest duty cycle sent to a servo \r\n#define DEFAULT_NEUTRAL_PULSE_WIDTH  1500 \/\/ default duty cycle when servo is attached<\/code><\/pre>\n\n\n\n<p>\u8aad\u307f\u8fbc\u307e\u308c\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u306fPIO\u30db\u30fc\u30e0 -> Libraries -> Built-in\u304b\u3089\uff08\u5fc5\u8981\u306a\u3089\u691c\u7d22\u3067\u7d5e\u3063\u3066\uff09Servo\u3092\u9078\u3093\u3067Reveal\u3092\u62bc\u3059\u3068\u78ba\u8a8d\u53ef\u80fd\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u74b0\u5883 \u4e8b\u8c61 SG90\u3092PlatformIO\u3067\u5165\u308c\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u30670,90,180\u5ea6\u3067\u52d5\u304b\u305d\u3046\u3068\u3057\u305f\u3068\u3053\u308d\u305d\u308c\u305e\u308c0,45,90\u5ea6\u3050\u3089\u3044\u3057\u304b\u52d5\u304b\u306a\u304b\u3063\u305f \u30bd\u30fc\u30b9\u306f\u4ee5\u4e0b servoMotor.readMicroseconds( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78,117],"tags":[],"class_list":["post-1763","post","type-post","status-publish","format-standard","hentry","category-78","category-117"],"_links":{"self":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts\/1763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1763"}],"version-history":[{"count":1,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts\/1763\/revisions"}],"predecessor-version":[{"id":1764,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts\/1763\/revisions\/1764"}],"wp:attachment":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}