{"id":7178,"date":"2021-12-24T06:24:54","date_gmt":"2021-12-24T06:24:54","guid":{"rendered":"https:\/\/www.qec.tw\/?p=7178"},"modified":"2021-12-28T09:26:08","modified_gmt":"2021-12-28T09:26:08","slug":"functions","status":"publish","type":"post","link":"https:\/\/www.qec.tw\/ja\/86duino-reference\/functions\/","title":{"rendered":"\u6a5f\u80fd"},"content":{"rendered":"<p class=\"wp-block-paragraph\">\u30b3\u30fc\u30c9\u3092\u95a2\u6570\u306b\u5206\u5272\u3059\u308b\u3053\u3068\u3067\u3001\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306f\u5b9a\u7fa9\u3055\u308c\u305f\u30bf\u30b9\u30af\u3092\u5b9f\u884c\u3057\u3001\u95a2\u6570\u304c\u300c\u547c\u3073\u51fa\u3055\u308c\u305f\u300d\u30b3\u30fc\u30c9\u9818\u57df\u306b\u623b\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u5316\u3055\u308c\u305f\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b\u5178\u578b\u7684\u306a\u30b1\u30fc\u30b9\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u5185\u3067\u540c\u3058\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u8907\u6570\u56de\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">BASIC \u306b\u6163\u308c\u305f\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306b\u3068\u3063\u3066\u300186Duino \u306e\u95a2\u6570\u306f\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3 (BASIC \u306e GOSUB) \u3092\u4f7f\u7528\u3059\u308b\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u3092\u63d0\u4f9b (\u304a\u3088\u3073\u62e1\u5f35) \u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b3\u30fc\u30c9\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u3092\u95a2\u6570\u306b\u6a19\u6e96\u5316\u3059\u308b\u3068\u3001\u3044\u304f\u3064\u304b\u306e\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u95a2\u6570\u306f\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u6574\u7406\u6574\u9813\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002\u591a\u304f\u306e\u5834\u5408\u3001\u95a2\u6570\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6982\u5ff5\u5316\u3059\u308b\u306e\u306b\u3082\u5f79\u7acb\u3061\u307e\u3059\u3002<\/li><li>\u95a2\u6570\u306f 1 \u3064\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092 1 \u304b\u6240\u306b\u30b3\u30fc\u30c9\u5316\u3059\u308b\u305f\u3081\u3001\u95a2\u6570\u306e\u691c\u8a0e\u3068\u30c7\u30d0\u30c3\u30b0\u306f 1 \u56de\u3060\u3051\u3067\u6e08\u307f\u307e\u3059\u3002<\/li><li>\u3053\u308c\u306b\u3088\u308a\u3001\u30b3\u30fc\u30c9\u3092\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u3067\u3082\u3001\u5909\u66f4\u6642\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u6e1b\u308a\u307e\u3059\u3002<\/li><li>\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30b3\u30fc\u30c9\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u304c\u4f55\u5ea6\u3082\u518d\u5229\u7528\u3055\u308c\u308b\u305f\u3081\u3001\u30b9\u30b1\u30c3\u30c1\u5168\u4f53\u304c\u3088\u308a\u5c0f\u3055\u304f\u30b3\u30f3\u30d1\u30af\u30c8\u306b\u306a\u308a\u307e\u3059\u3002<\/li><li>\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30b3\u30fc\u30c9\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u5316\u304c\u4fc3\u9032\u3055\u308c\u3001\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306e\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u5b09\u3057\u3044\u526f\u4f5c\u7528\u3068\u3057\u3066\u3001\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3068\u30b3\u30fc\u30c9\u306e\u8aad\u307f\u3084\u3059\u3055\u3082\u5411\u4e0a\u3057\u307e\u3059\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">86Duino\u30b9\u30b1\u30c3\u30c1\u306b\u306f\u3001<code>setup()<\/code>\u3068<code>loop()<\/code>\u3068\u3044\u30462\u3064\u306e\u5fc5\u9808\u95a2\u6570\u304c\u3042\u308a\u307e\u3059\u3002\u4ed6\u306e\u95a2\u6570\u306f\u3001\u3053\u308c\u30892\u3064\u306e\u95a2\u6570\u306e\u62ec\u5f27\u306e\u5916\u5074\u306b\u8a18\u8ff0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4f8b\u3068\u3057\u3066\u30012\u3064\u306e\u6570\u5024\u3092\u639b\u3051\u5408\u308f\u305b\u308b\u5358\u7d14\u306a\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8b\u4f8b<\/h2>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img fetchpriority=\"high\" decoding=\"async\" src=\"http:\/\/www.86duino.com\/wp-content\/uploads\/2013\/12\/FuncAnatomy.png\" alt=\"FuncAnatomy\" width=\"413\" height=\"275\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5358\u7d14\u306a\u4e57\u7b97\u95a2\u6570\u3092\u300c\u547c\u3073\u51fa\u3059\u300d\u306b\u306f\u3001\u671f\u5f85\u3059\u308b\u30c7\u30fc\u30bf\u578b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>void loop{\n  int i = 2;\n  int j = 3;\n  int k;\n \n  k = myMultiplyFunction(i, j); \/\/ k now contains 6\n}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">\u3053\u306e\u95a2\u6570\u306f\u4ed6\u306e\u95a2\u6570\u306e\u5916\u5074\u3067\u5ba3\u8a00\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3001\u300c<code>myMultiplyFunction()<\/code>\u300d\u306f\u300c<code>loop()<\/code>\u300d\u95a2\u6570\u306e\u4e0a\u307e\u305f\u306f\u4e0b\u306e\u3069\u3061\u3089\u306b\u3082\u914d\u7f6e\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b9\u30b1\u30c3\u30c1\u5168\u4f53\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>void setup(){\n  Serial.begin(9600);\n}\n \nvoid loop() {\n  int i = 2;\n  int j = 3;\n  int k;\n \n  k = myMultiplyFunction(i, j); \/\/ k now contains 6\n  Serial.println(k);\n  delay(500);\n}\n \nint myMultiplyFunction(int x, int y){\n  int result;\n  result = x * y;\n  return result;\n}<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u5225\u306e\u4f8b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">\u3053\u306e\u95a2\u6570\u306f\u3001<code>analogRead()<\/code> \u3092\u4f7f\u3063\u3066\u30bb\u30f3\u30b5\u30fc\u30925\u56de\u8aad\u307f\u53d6\u308a\u30015\u56de\u306e\u8aad\u307f\u53d6\u308a\u5024\u306e\u5e73\u5747\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001\u30c7\u30fc\u30bf\u30928\u30d3\u30c3\u30c8\uff080\uff5e255\uff09\u306b\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u3057\u3001\u53cd\u8ee2\u3057\u3066\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>int ReadSens_and_Condition(){\n  int i;\n  int sval = 0;\n \n  for (i = 0; i &lt; 5; i++){\n    sval = sval + analogRead(0);    \/\/ sensor on analog pin 0\n  }\n \n  sval = sval \/ 5;    \/\/ average\n  sval = sval \/ 4;    \/\/ scale to 8 bits (0 - 255)\n  sval = 255 - sval;  \/\/ invert output\n  return sval;\n}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u306b\u306f\u3001\u305d\u308c\u3092\u5909\u6570\u306b\u5272\u308a\u5f53\u3066\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>int sens;\n \nsens = ReadSens_and_Condition();<\/pre><\/div>\n\n\n<hr \/>\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.qec.tw\/ja\/86duino\/86duino-language-reference\/\">Language Reference Home<\/a><\/h3>\n\n\n\n<p class=\"wp-block-paragraph translation-block\"><em>86Duino\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306e\u30c6\u30ad\u30b9\u30c8\u306f\u3001<a href=\"http:\/\/arduino.cc\/en\/Reference\/HomePage\" target=\"_self\">Arduino\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a>\u3092\u6539\u5909\u3057\u305f\u3082\u306e\u3067\u3001<a href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/\" target=\"_self\">Creative Commons Attribution-ShareAlike 3.0\u30e9\u30a4\u30bb\u30f3\u30b9<\/a>\u306b\u57fa\u3065\u3044\u3066\u30e9\u30a4\u30bb\u30f3\u30b9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u5185\u306e\u30b3\u30fc\u30c9\u30b5\u30f3\u30d7\u30eb\u306f\u30d1\u30d6\u30ea\u30c3\u30af\u30c9\u30e1\u30a4\u30f3\u3068\u3057\u3066\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>Segmenting code into functions allows a programmer to create modular pieces of code that perform a defined task and then return to the area of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7179,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[195],"tags":[162],"class_list":["post-7178","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-86duino-reference","tag-86duino"],"_links":{"self":[{"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/posts\/7178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/comments?post=7178"}],"version-history":[{"count":0,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/posts\/7178\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/media\/7179"}],"wp:attachment":[{"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/media?parent=7178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/categories?post=7178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/tags?post=7178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}