{"id":7168,"date":"2015-05-17T02:28:23","date_gmt":"2015-05-16T17:28:23","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=7168"},"modified":"2015-05-17T02:29:09","modified_gmt":"2015-05-16T17:29:09","slug":"windows-remote-arduino-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%a6-arduino-%e6%88%a6%e8%bb%8a%e3%82%92%e5%8b%95%e3%81%8b%e3%81%99","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/7168","title":{"rendered":"Windows Remote Arduino \u3092\u5229\u7528\u3057\u3066 Arduino \u6226\u8eca\u3092\u52d5\u304b\u3059"},"content":{"rendered":"<p>Windows Remote Arduino \u3092 Arduino Uno\/Nano \u3067\u8a66\u3059 | Moonmile Solutions Blog<br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/archives\/7158\">http:\/\/www.moonmile.net\/blog\/archives\/7158<\/a><\/p>\n<p>\u306e\u7d9a\u304d\u3067\u3059\u3002Arduino \u306b Firmata \u3092\u5165\u308c\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067 Arduino \u3092\u30ea\u30e2\u30fc\u30c8\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u624b\u5143\u306b\u3042\u308b Arduino \u6226\u8eca\u306b Firmata \u3092\u5165\u308c\u76f4\u3057\u3001Windows Remote Arduino \u3092\u4f7f\u3063\u3066\u30bf\u30d6\u30ec\u30c3\u30c8\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/archives\/7012\">L293D \u5229\u7528\u3057\u3066 Arduino \u6226\u8eca\u3092\u4f5c\u308b | Moonmile Solutions Blog<\/a> \u3067\u4f5c\u3063\u305f Arduino \u6226\u8eca\u306f\u81ea\u524d\u3067 \u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u90e8\u5206\u3092\u66f8\u3044\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001Firmata \u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u76f4\u305b\u3070\u3001Ruby \u3068\u304b Node.js \u304b\u3089\u3082\u52d5\u304b\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3088\u306d\u3002\u305d\u306e\u3042\u305f\u308a\u306e\u76f8\u4e92\u901a\u4fe1\u306f Alljoyn \u3067\u3084\u308b\u3088\u3046\u306b\u306a\u308b\u30cf\u30ba\u306a\u306e\u3067\u3059\u304c\u3001\u3072\u3068\u307e\u305a Firmata \u3067\u52d5\u304b\u3057\u307e\u3059\uff08\u30c7\u30d5\u30a1\u30af\u30c8\u30b9\u30bf\u30f3\u30c0\u30fc\u30c9\u3063\u307d\u3044\u3057\uff09\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/05\/image19.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/05\/image_thumb19.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"534\" height=\"492\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u306e UI \u3092\u4f5c\u3063\u3066\u3001\u30dc\u30bf\u30f3\u3092\u30bf\u30c3\u30d7\u3057\u3066 Arduino \u6226\u8eca\u3092\u52d5\u304b\u3057\u307e\u3059\u3002\u30b3\u30fc\u30c9\u3067\u3001AddHandler \u3057\u3066\u3044\u308b\u306e\u306f\u3001\u30dc\u30bf\u30f3\u3092\u30bf\u30c3\u30d7\u3057\u3066\u3044\u308b\u9593\u3060\u3051\u30e2\u30fc\u30bf\u30fc\u3092\u52d5\u304b\u3057\u305f\u304b\u3063\u305f\u304b\u3089\u3067\u3059\u3002\u9014\u4e2d\u3067\u901a\u4fe1\u304c\u66b4\u8d70\u3059\u308b\u3068\u3001\u6226\u8eca\u81ea\u4f53\u304c\u66b4\u8d70\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u6226\u8eca\u304c\u6b62\u307e\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u69cb\u6210\u306f\u3001Microsoft.Maker.* \u3092\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u306b\u52a0\u3048\u3066\u30d3\u30eb\u30c9\u3002\u30e1\u30a4\u30f3\u306e ArduinoTankFirmata \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304b\u3089\u5404\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u53c2\u7167\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/05\/image20.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/05\/image_thumb20.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"434\" height=\"391\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u3056\u3063\u3068\u66f8\u3044\u305f\u306e\u304c\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002Arduino \u6226\u8eca\u306e Bluetooth \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u540d\u524d\u304c\u300cHC-05\u300d\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u30e2\u30fc\u30bf\u99c6\u52d5\u306e\u305f\u3081\u306e\u30d4\u30f3\uff085-7,8-10\uff09\u3092\u3044\u3061\u3044\u3061\u5236\u5fa1\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u304c\u3001Arduino \u306e Sketch \u3068\u540c\u3058\u3088\u3046\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\"> \r\npublic sealed partial class MainPage : Page\r\n{\r\n    BluetoothSerial bluetooth;\r\n    RemoteDevice arduino;\r\n\r\n    public MainPage()\r\n    {\r\n        this.InitializeComponent();\r\n        this.Loaded += MainPage_Loaded;\r\n\r\n        foreach (var b in new Button&#x5B;] { ledRed, ledYellow, ledBlue })\r\n        {\r\n            b.AddHandler(PointerPressedEvent, new PointerEventHandler(OnLedPressed), true);\r\n            b.AddHandler(PointerReleasedEvent, new PointerEventHandler(OnLedReleased), true);\r\n        }\r\n        tankStop.Click += (s, e) =&gt; { MotorLeftStop(); MotorRightStop(); };\r\n        foreach (var b in new Button&#x5B;] { tankForward, tankBack, tankLeft, tankRight })\r\n        {\r\n            b.AddHandler(PointerPressedEvent, new PointerEventHandler(OnTankPressed), true);\r\n            b.AddHandler(PointerReleasedEvent, new PointerEventHandler(OnTankReleased), true);\r\n        }\r\n\r\n    }\r\n\r\n    void MainPage_Loaded(object sender, RoutedEventArgs e)\r\n    {\r\n        bluetooth = new BluetoothSerial(&amp;quot;HC-05&amp;quot;);\r\n        arduino = new RemoteDevice(bluetooth);\r\n        bluetooth.ConnectionEstablished += bluetooth_ConnectionEstablished;\r\n        bluetooth.begin(9600, SerialConfig.SERIAL_8N1);\r\n    }\r\n\r\n    async void bluetooth_ConnectionEstablished()\r\n    {\r\n        await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&gt; {\r\n            this.textStatus.Text = &amp;quot;\u63a5\u7d9a\u3057\u307e\u3057\u305f&amp;quot;;\r\n        });\r\n    }\r\n\r\n    const int pinLedRed = 13;\r\n    const int pinLedYellow = 12;\r\n    const int pinLedBlue = 11;\r\n\r\n    const int pinMotorAPower = 10;\r\n    const int pinMotorAOut1 = 9;\r\n    const int pinMotorAOut2 = 8;\r\n    const int pinMotorBPower = 5;\r\n    const int pinMotorBOut1 = 6;\r\n    const int pinMotorBOut2 = 7;\r\n\r\n    void OnLedPressed(object sender, PointerRoutedEventArgs e)\r\n    {\r\n        if (sender == ledRed) arduino.digitalWrite(pinLedRed, PinState.HIGH);\r\n        if (sender == ledYellow) arduino.digitalWrite(pinLedYellow, PinState.HIGH);\r\n        if (sender == ledBlue) arduino.digitalWrite(pinLedBlue, PinState.HIGH);\r\n    }\r\n    void OnLedReleased(object sender, PointerRoutedEventArgs e)\r\n    {\r\n        if (sender == ledRed) arduino.digitalWrite(pinLedRed, PinState.LOW);\r\n        if (sender == ledYellow) arduino.digitalWrite(pinLedYellow, PinState.LOW);\r\n        if (sender == ledBlue) arduino.digitalWrite(pinLedBlue, PinState.LOW);\r\n    }\r\n\r\n    void OnTankPressed(object sender, PointerRoutedEventArgs e)\r\n    {\r\n        if (sender == tankForward) { MotorLeftForward(); MotorRightForward(); };\r\n        if (sender == tankBack) { MotorLeftBack(); MotorRightBack(); };\r\n        if (sender == tankLeft) { MotorLeftBack(); MotorRightForward(); };\r\n        if (sender == tankRight) { MotorLeftForward(); MotorRightBack(); };\r\n\r\n    }\r\n    void OnTankReleased(object sender, PointerRoutedEventArgs e)\r\n    {\r\n        MotorLeftStop();\r\n        MotorRightStop();\r\n    }\r\n\r\n    void MotorLeftStop()\r\n    {\r\n        arduino.digitalWrite( pinMotorAPower, PinState.LOW );\r\n        arduino.digitalWrite(pinMotorAOut1, PinState.LOW);\r\n        arduino.digitalWrite(pinMotorAOut2, PinState.LOW);\r\n    }\r\n    void MotorLeftForward()\r\n    {\r\n        arduino.digitalWrite(pinMotorAPower, PinState.HIGH);\r\n        arduino.digitalWrite(pinMotorAOut1, PinState.LOW);\r\n        arduino.digitalWrite(pinMotorAOut2, PinState.HIGH);\r\n    }\r\n    void MotorLeftBack()\r\n    {\r\n        arduino.digitalWrite(pinMotorAPower, PinState.HIGH);\r\n        arduino.digitalWrite(pinMotorAOut1, PinState.HIGH);\r\n        arduino.digitalWrite(pinMotorAOut2, PinState.LOW);\r\n    }\r\n    void MotorRightStop()\r\n    {\r\n        arduino.digitalWrite(pinMotorBPower, PinState.LOW);\r\n        arduino.digitalWrite(pinMotorBOut1, PinState.LOW);\r\n        arduino.digitalWrite(pinMotorBOut2, PinState.LOW);\r\n    }\r\n    void MotorRightForward()\r\n    {\r\n        arduino.digitalWrite(pinMotorBPower, PinState.HIGH);\r\n        arduino.digitalWrite(pinMotorBOut1, PinState.LOW);\r\n        arduino.digitalWrite(pinMotorBOut2, PinState.HIGH);\r\n    }\r\n    void MotorRightBack()\r\n    {\r\n        arduino.digitalWrite(pinMotorBPower, PinState.HIGH);\r\n        arduino.digitalWrite(pinMotorBOut1, PinState.HIGH);\r\n        arduino.digitalWrite(pinMotorBOut2, PinState.LOW);\r\n    }\r\n}\r\n<\/pre>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3001\u53bb\u5e74\u306e de:code \u3067\u8cb0\u3063\u305f Toshiba \u306e\u30bf\u30d6\u30ec\u30c3\u30c8\u306b\u5165\u308c\u3066\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u307e\u3059\u3002Toshiba \u30bf\u30d6\u30ec\u30c3\u30c8\u306b Windows 10 IP \u3092\u5165\u308c\u3088\u3046\u3068\u3057\u305f\u306e\u3067\u3059\u304c\u3001\u5931\u6557\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u3001Windows 8.1 \u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/pbs.twimg.com\/media\/CFJIDyFVEAAvMYf.jpg\" alt=\"https:\/\/pbs.twimg.com\/media\/CFJIDyFVEAAvMYf.jpg\" \/><\/p>\n<p>\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u306e\u3088\u3046\u306a\u81ea\u5f8b\u7684\u306a\u52d5\u304d\u3092\u3059\u308b\u5834\u5408\u306f\u3001Firmata \u7d4c\u7531\u3067\u306f\u5197\u9577\u306a\u51e6\u7406\u306b\u306a\u3063\u3066\u3044\u3057\u307e\u3046\u306e\u3067\u3059\u304c\uff08\u30bb\u30f3\u30b5\u30fc\u3092 BT \u3067\u98db\u3070\u3057\u3066 PC \u3067\u5236\u5fa1\u3059\u308b\u3068\u3044\u3046\u30b9\u30bf\u30a4\u30eb\u306b\u306a\u308b\u306e\u3067\uff09\u3001Arduino \u306e\u30bb\u30f3\u30b7\u30f3\u30b0\u30c7\u30fc\u30bf\u3092\u305d\u306e\u307e\u307e\u9001\u3063\u3066\u304d\u305f\u308a\u3001\u4eca\u56de\u306e\u3088\u3046\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u76f4\u63a5\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3059\u308b\u5834\u5408\u306b\u306f\u3001\u3055\u3063\u304f\u308a\u3068\u4f5c\u308c\u3066\u3088\u3055\u305d\u3046\u3067\u3059\u3002GPIO \u306e\u4f7f\u3044\u65b9\u306f Sketch \u306b\u4f3c\u3066\u3044\u308b\u3093\u3067\u3059\u304c\u3001\u500b\u4eba\u7684\u306b\u306f .NET micro \u98a8\u306b\u3057\u3066\u3082\u3088\u304b\u3063\u305f\u306e\u3067\u306f\uff1f\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u304c\u3002\u307e\u3042\u3001\u305d\u306e\u3042\u305f\u308a\u306f\u81ea\u5206\u3067\u62e1\u5f35\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u308c\u3070\u3088\u3044\u308f\u3051\u3067\u3001\u305d\u306e\u8fba\u306f\u3044\u305a\u308c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Remote Arduino \u3092 Arduino Uno\/Nano \u3067\u8a66\u3059 | Moonmile Solutions Blog http:\/\/www.moonmile.net\/blog\/archives\/ &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/7168\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[71,77],"tags":[],"class_list":["post-7168","post","type-post","status-publish","format-standard","hentry","category-arduino","category-win-iot"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=7168"}],"version-history":[{"count":2,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7168\/revisions"}],"predecessor-version":[{"id":7170,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7168\/revisions\/7170"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=7168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=7168"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=7168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}