{"id":3803,"date":"2017-07-01T13:58:04","date_gmt":"2017-07-01T04:58:04","guid":{"rendered":"https:\/\/www.chihayafuru.jp\/etrobo\/?p=3803"},"modified":"2017-12-11T20:14:16","modified_gmt":"2017-12-11T11:14:16","slug":"swift-playgrounds%e3%81%a7%e3%83%a9%e3%82%a4%e3%83%b3%e3%83%88%e3%83%ac%e3%83%bc%e3%82%b9","status":"publish","type":"post","link":"https:\/\/www.chihayafuru.jp\/etrobo\/?p=3803","title":{"rendered":"Swift Playgrounds\u3067\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9"},"content":{"rendered":"<p>Swift\u306e\u5b66\u7fd2\u3092\u30bf\u30d6\u30ec\u30c3\u30c8\u3067\u624b\u8efd\u306b\u8a66\u3059\u3053\u3068\u304c\u3067\u304d\u308bApple\u793e\u306e\u516c\u5f0fiPad\u30a2\u30d7\u30ea &quot;Swift Playgrounds&quot; \u304c2017\u5e746\u6708\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u3055\u308c\u307e\u3057\u305f\u3002\u3053\u306e Swift Playgrounds ver.1.5 \u306b\u3066\u3001LEGO Mindstorms EV3\u3078\u306e\u5bfe\u5fdc\u3082\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3053\u3067 Swift Playgrounds \u3067 Mindstorms EV3 \u3092\u5236\u5fa1\u3059\u308b\u4f8b\u3068\u3057\u3066\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u30fb\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>Swift Playgrounds \u3092\u4f7f\u3044\u3001Mindstorms EV3\u306e\uff13\u8f2a\u30ed\u30dc\u30c3\u30c8\u3067\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u3092\u5b9f\u884c\u3055\u305b\u3066\u307f\u305f\u52d5\u753b\u3067\u3059\u3002<br \/>\n<!--more--><\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/2zfturHGb4E?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<h1>\u611f\u60f3<\/h1>\n<p>\u3044\u3061\u3044\u3061\u6709\u7dda(USB)\u3092\u629c\u304d\u5dee\u3057\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u3001\u3068\u3044\u3046\u306e\u306f\u60f3\u50cf\u4ee5\u4e0a\u306b\u4fbf\u5229\u3067\u3057\u305f\u3002\u521d\u56de\u306biPad\u3068Mindstorms EV3\u3092Bluetooth\u3067\u30da\u30a2\u30ea\u30f3\u30b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u308c\u4ee5\u964d\u306fSwift Playground\u30a2\u30d7\u30ea\u3067\u300cEV3\u30d6\u30ed\u30c3\u30af\u3092\u63a5\u7d9a\u300d\u30dc\u30bf\u30f3\u3092\u30bf\u30c3\u30d7\u3059\u308b\u3060\u3051\u3067\u3059\u3002iPad\u304b\u3089\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u306b\u63a5\u7d9a\u3059\u308b\u3068\u304d\u306b\u306f\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u306b\u8a2d\u5b9a\u3057\u305f\u540d\u524d\u304b\u3089\u9078\u3076\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3001\u3082\u3057\u6559\u5ba4\u306e\u3088\u3046\u306a\u3068\u3053\u308d\u3067\u8907\u6570\u53f0\u306e\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u304c\u3042\u308b\u30b1\u30fc\u30b9\u3067\u306f\u3001\u4e00\u53f0\u4e00\u53f0\u7570\u306a\u308b\u540d\u524d\u306b\u5909\u66f4\u3057\u3066\u304a\u304b\u306a\u3044\u3068\u5927\u5909\u3060\u3068\u611f\u3058\u307e\u3057\u305f\u3002\u3057\u304b\u3057\uff11\u53f0\u3057\u304b\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u304c\u306a\u3044\u74b0\u5883\u3067\u3042\u308c\u3070\u30da\u30a2\u30ea\u30f3\u30b0\u3082\u3001\u305d\u306e\u5f8c\u306e\u63a5\u7d9a\u3082\u82e6\u52b4\u306f\u306a\u3044\u3068\u304a\u3082\u3044\u307e\u3059\u3002<\/p>\n<h3>EV3\u306e\u540d\u524d\u3092\u5909\u66f4\u3059\u308b\u306b\u306f &#8211; \u682a\u5f0f\u4f1a\u793e\u30a2\u30d5\u30ec\u30eb<\/h3>\n<blockquote><p><a href=\"https:\/\/afrel.co.jp\/archives\/15581\">https:\/\/afrel.co.jp\/archives\/15581<\/a><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>\u307e\u305f\u3001\u300c\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u300d\u30dc\u30bf\u30f3\u3092\u4e00\u767a\u30bf\u30c3\u30d7\u3059\u308b\u3060\u3051\u3067\u3001\u300c\u30b3\u30f3\u30d1\u30a4\u30eb\u300d\u3084\u300c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u300d\u3068\u3044\u3063\u305f\u5197\u9577\u306a\u624b\u9806\u3092\u610f\u8b58\u3059\u308b\u5fc5\u8981\u306a\u304f\u3001\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u3066\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u304c\u52d5\u304d\u51fa\u3059\u3068\u3044\u3046\u306e\u3082\u76f4\u611f\u7684\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u3068\u611f\u3058\u307e\u3057\u305f\u3002\u30b3\u30fc\u30c9\u306b\u9593\u9055\u3044\u3084\u4e0d\u8db3\u304c\u3042\u308b\u3068\u3001\uff11\u301c\uff12\u30ef\u30fc\u30c9\u5165\u529b\u3057\u305f\u9014\u7aef\u306b\u8b66\u544a\u3084\u30b5\u30b8\u30a7\u30c3\u30b7\u30e7\u30f3\u304c\u8868\u793a\u3055\u308c\u308b\u305f\u3081\u3001\u6163\u308c\u3066\u304f\u308b\u3068\u82e5\u5e72\u3046\u308b\u3055\u304f\u611f\u3058\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u30b3\u30fc\u30c9\u306e\u5165\u529b\u3092\u5168\u3066\u7d42\u3048\u3066\uff08\u7d42\u3048\u305f\u3064\u3082\u308a\u3067\uff09\u5b9f\u884c\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u304b\u3089\u521d\u3081\u3066\u30b3\u30fc\u30c9\u306e\u9593\u9055\u3044\u306b\u6c17\u3065\u304d\u4f5c\u696d\u3092\u5f8c\u623b\u308a\u3059\u308b\u3053\u3068\u306f\u907f\u3051\u3089\u308c\u308b\u3088\u3046\u306b\u5de5\u592b\u3055\u308c\u3066\u3044\u308b\u3068\u611f\u3058\u307e\u3059\u3002<\/p>\n<p>\u30e2\u30fc\u30bf\u30fc\u306e\u56de\u8ee2\u89d2\u5ea6\u306e\u53d6\u5f97\u3084\u30bb\u30f3\u30b5\u30fc\u306b\u3088\u308b\u6e2c\u5b9a\u306b\u9762\u5012\u306a\u8a2d\u5b9a\u306e\u5fc5\u8981\u304c\u306a\u304f\u3001\u30e1\u30cb\u30e5\u30fc\u5207\u308a\u66ff\u3048\u4e00\u767a\u3067\u6298\u308c\u7dda\u30b0\u30e9\u30d5\u3067\u8868\u793a\u3082\u3067\u304d\u308b\u306e\u3082\u3001\u3068\u3066\u3082\u3088\u304f\u3067\u304d\u305f\u5de5\u592b\u3060\u3068\u601d\u3044\u307e\u3059\u3002\u30b3\u30fc\u30c9\u3092\uff11\u884c\u3082\u66f8\u304b\u306a\u304f\u3066\u3082\u3001\u3072\u3068\u307e\u305a\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u3068iPad\u3092Bluetooth\u3067\u63a5\u7d9a\u3057\u3066\u3001\u30e2\u30fc\u30bf\u30fc\uff08\u30bf\u30a4\u30e4\uff09\u3092\u624b\u3067\u56de\u3059\u3068\u3001\u305d\u306e\u7d50\u679c\u304ciPad\u3067\u898b\u308c\u308b\u3068\u3044\u3046\u306e\u306f\u3068\u3066\u3082\u4fbf\u5229\u3067\u3059\u3002\u300c\u53f3\u306e\u30bf\u30a4\u30e4\uff08\u30e2\u30fc\u30bf\u30fc\uff09\u3092\u30dd\u30fc\u30c8B\u306b\u7e4b\u3044\u3060\u3064\u3082\u308a\u304c\u3001\u5b9f\u306f\u30dd\u30fc\u30c8C\u306b\u7e4b\u3044\u3067\u3044\u305f\uff01\u300d\u306a\u3093\u3066\u5358\u7d14\u306a\u9593\u9055\u3044\u306b\u6c17\u3065\u304f\u307e\u3067\u306b\u4f55\u5206\u3082\u982d\u3092\u304b\u304b\u3048\u308b\u3053\u3068\u306f\u3001\u3053\u308c\u3067\u306a\u304f\u306a\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u4e00\u70b9\u3060\u3051\u6c17\u306b\u306a\u3063\u305f\u306e\u306fiPad\u3068\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u306e\u9593\u306eBluetooth\u901a\u4fe1\u3067\u751f\u3058\u308b\u9045\u5ef6\u3067\u3059\u3002Swift Playgrounds\u3067\u4f5c\u6210\u3057\u305f\u30b3\u30fc\u30c9\u306f\u30b3\u30fc\u30c9\u5168\u4f53\u3092\u4e00\u62ec\u3057\u3066\u30de\u30a4\u30f3\u30c9\u30b9\u30c8\u30fc\u30e0\u306b\u9001\u308a\u8fbc\u3080\uff08\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\uff09\u308f\u3051\u3067\u306f\u306a\u304f\u3001\u30c0\u30a4\u30ec\u30af\u30c8\u30b3\u30de\u30f3\u30c9\u3068\u3088\u3070\u308c\u308b\u30b3\u30de\u30f3\u30c9\u5358\u4f4d\u3067\uff11\u30b9\u30c6\u30c3\u30d7\u305a\u3064\u5c0f\u5206\u3051\u306b\u9001\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001\u3069\u3061\u3089\u3082<\/p>\n<ul>\n<li>\u5de6\uff08\u30dd\u30fc\u30c8A\u306b\u7e4b\u304c\u3063\u305f\uff09\u30e2\u30fc\u30bf\u30fc\u309210.0\u306e\u30d1\u30ef\u30fc\u3067\u56de\u8ee2<\/li>\n<li>\u53f3\uff08\u30dd\u30fc\u30c8D\u306b\u7e4b\u304c\u3063\u305f\uff09\u30e2\u30fc\u30bf\u30fc\u309210.0\u306e\u30d1\u30ef\u30fc\u3067\u56de\u8ee2<\/li>\n<\/ul>\n<p>\u3057\u3066\u3044\u308b\u306e\u3067\u52d5\u304d\u306f\u540c\u3058\u306b\u306a\u308b\u3088\u3046\u306b\u601d\u308f\u308c\u307e\u3059\u3002<\/p>\n<h2>\u5de6\u53f3\uff08\uff12\u3064\uff09\u306e\u30e2\u30fc\u30bf\u30fc\u306e\u30d1\u30ef\u30fc\u3092\uff11\u5ea6\u306b\u9001\u4fe1\u3059\u308b\u4f8b<\/h2>\n<pre class=\"lang:swift decode:true \" title=\"\u5de6\u53f3\uff08\uff12\u3064\uff09\u30e2\u30fc\u30bf\u30fc\u306e\u30d1\u30ef\u30fc\u3092\uff11\u5ea6\u306b\u9001\u4fe1\" >ev3.move(leftPort: .a, rightPort: .d, leftPower: 10.0, rightPower: 10.0)<\/pre>\n<h2>\u5de6\u53f3\uff08\uff12\u3064\uff09\u306e\u30e2\u30fc\u30bf\u30fc\u306e\u30d1\u30ef\u30fc\u3092\uff12\u5ea6\u306b\u5206\u3051\u3066\u9001\u4fe1\u3059\u308b\u4f8b<\/h2>\n<pre class=\"lang:swift decode:true \" title=\"\u5de6\u53f3\uff08\uff12\u3064\uff09\u30e2\u30fc\u30bf\u30fc\u306e\u30d1\u30ef\u30fc\u3092\uff12\u5ea6\u306b\u5206\u3051\u3066\u9001\u4fe1\" >ev3.motorOn(on:.a, withPower:10.0)\r\nev3.motorOn(on:.d, withPower:10.0)<\/pre>\n<p>\u3068\u3053\u308d\u304c\uff12\u3064\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u969b\u306b\u52d5\u304b\u3057\u3066\u307f\u308b\u3068\u3001\u5f8c\u8005\u306e\u300c\u5de6\u53f3\u306e\u30e2\u30fc\u30bf\u30fc\u306e\u30d1\u30ef\u30fc\u3092\uff12\u5ea6\u306b\u5206\u3051\u3066\u9001\u4fe1\u3059\u308b\u4f8b\u300d\u3067\u306f\u5de6\uff08\u30dd\u30fc\u30c8A\uff09\u306e\u30e2\u30fc\u30bf\u30fc\u304c\u5148\u306b\u56de\u8ee2\u3057\u3066\u304b\u3089\u5c11\u3057\uff08\u6570\u767e\u30df\u30ea\u79d2\uff09\u9045\u308c\u3066\u3001\u53f3\uff08\u30dd\u30fc\u30c8D\uff09\u306e\u30e2\u30fc\u30bf\u30fc\u304c\u56de\u8ee2\u3059\u308b\u3001\u3068\u3044\u3046\u73fe\u8c61\u304c\u898b\u3089\u308c\u307e\u3059\u3002\u30ed\u30dc\u30c3\u30c8\u306e\u69cb\u9020\u306b\u3088\u3063\u3066\u306f\uff12\u3064\u306e\u30e2\u30fc\u30bf\u30fc\u306e\u56de\u8ee2\u304c\uff11\u79d2\u4ee5\u4e0b\u306e\u77ed\u3044\u6642\u9593\u3067\u9045\u308c\u3066\u3082\uff08\u305a\u308c\u3066\u3082\uff09\u554f\u984c\u306b\u306f\u306a\u3089\u306a\u3044\u3068\u304a\u3082\u3044\u307e\u3059\u304c\u3001\u5de6\u53f3\u306b\u4e26\u3079\u305f\u30e2\u30fc\u30bf\u30fc\uff08\u30bf\u30a4\u30e4\uff09\u3092\u4e26\u884c\u3057\u3066\u5236\u5fa1\u3059\u308b\u3088\u3046\u306a\u30b1\u30fc\u30b9\u3067\u306f\u3001\u6b63\u9762\u306b\u5411\u304b\u3063\u3066\u671f\u5f85\u3057\u305f\u901a\u308a\u306b\u306f\u8d70\u3089\u305a\u306b\u56f0\u3063\u3066\u3057\u307e\u3046\u30b1\u30fc\u30b9\u304c\u767a\u751f\u3059\u308b\u3088\u3046\u306b\u601d\u308f\u308c\u307e\u3059\u3002\u3060\u304b\u3089Swift Playgrounds\u3082\u300c\u4e8c\u3064\u306e\u30e2\u30fc\u30bf\u30fc\u306e\u30d1\u30ef\u30fc\u3092\uff11\u5ea6\u306b\u9001\u4fe1\u3059\u308b\u300d\u3068\u3044\u3046\u4e00\u898b\u5197\u9577\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3057\u3066\u3044\u308b\u306e\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u901a\u4fe1\u306b\u3088\u308b\u9045\u5ef6\u306f\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u306b\u304a\u3051\u308b\u300c\u5149\u30bb\u30f3\u30b5\u30fc\u306e\u6e2c\u5b9a\u5024\u3092\u8aad\u307f\u53d6\u3063\u3066\u3001\u305d\u306e\u7d50\u679c\u3067\u5de6\u53f3\u306e\u30e2\u30fc\u30bf\u30fc\u306e\u56de\u8ee2\uff08\u30d1\u30ef\u30fc\uff09\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3059\u308b\u300d\u3068\u3044\u3046\u51e6\u7406\u3067\u3082\u60aa\u3044\u5f71\u97ff\u3092\u53ca\u307c\u3057\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u4e0b\u8a18\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3082\u3001\u30e2\u30fc\u30bf\u30fc\u306e\u30d1\u30ef\u30fc\u3092\u6291\u3048\u6c17\u5473\u306b\u3057\u3066\u30ed\u30dc\u30c3\u30c8\u306e\u5236\u5fa1\u304c\u9593\u306b\u5408\u308f\u306a\u304f\u306a\u308b\u4e8b\u614b\u3092\u907f\u3051\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u5b9f\u969b\u306b\u8a66\u3057\u3066\u898b\u305f\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u306e\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"lang:swift decode:true \" >let threshold = Float(15.0)\r\nwhile true {\r\n    let light = ev3.measureLightReflection(on: .three)\r\n    if light &gt; threshold {\r\n        ev3.brickLightOn(withColor: .orange, inMode: .on)\r\n        ev3.move(leftPort: .a, rightPort: .d, leftPower: 3.0, rightPower: 5.0)\r\n    } else {\r\n        ev3.brickLightOff()\r\n        ev3.move(leftPort: .a, rightPort: .d, leftPower: 5.0, rightPower: 3.0)\r\n    }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Swift\u306e\u5b66\u7fd2\u3092\u30bf\u30d6\u30ec\u30c3\u30c8\u3067\u624b\u8efd\u306b\u8a66\u3059\u3053\u3068\u304c\u3067\u304d\u308bApple\u793e\u306e\u516c\u5f0fiPad\u30a2\u30d7\u30ea &quot;Swift Playgrounds&quot; \u304c2017\u5e746\u6708\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u3055\u308c\u307e\u3057\u305f\u3002\u3053\u306e Swift Playg &hellip; <a href=\"https:\/\/www.chihayafuru.jp\/etrobo\/?p=3803\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[35],"class_list":["post-3803","post","type-post","status-publish","format-standard","hentry","category-ev3","tag-ev3"],"_links":{"self":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts\/3803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3803"}],"version-history":[{"count":43,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts\/3803\/revisions"}],"predecessor-version":[{"id":4052,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts\/3803\/revisions\/4052"}],"wp:attachment":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}